Play Mp4 Video from Android Server

I want to play videos in mp4 format and 4-5Mb in size from the server in streaming mode. I am using sdk version 2.3, on the emulator this gives only sound but not image.

I also tested it on Samsung (android sdk ver 2.1) and LG optimus (android sdk ver 2.2) devices and only get the message โ€œcannot play video: sorry this video is not suitable for streaming to this deviceโ€. I was looking for this, but did not get any solution, if anyone has any solution, please help me. Thanks in advance.

Here is my code:

public class ShowVideo extends Activity { private static ProgressDialog progressDialog; public String video_url; private MediaController mediaController; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.videoalbum); progressDialog = ProgressDialog.show(ShowVideo.this, "", "Buffering video...", true); getWindow().setFormat(PixelFormat.TRANSLUCENT); video_url = "http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4"; try { final VideoView videoView =(VideoView)findViewById(R.id.video_viewId); mediaController = new MediaController(ShowVideo.this); mediaController.setAnchorView(videoView); // Set video link (mp4 format ) Uri video = Uri.parse(video_url); videoView.setMediaController(mediaController); videoView.setVideoURI(video); videoView.setOnPreparedListener(new OnPreparedListener() { public void onPrepared(MediaPlayer mp) { progressDialog.dismiss(); videoView.start(); } }); }catch(Exception e){ progressDialog.dismiss(); System.out.println("Video Play Error :"+e.getMessage()); } } 
+4
source share
2 answers

You can try these URLs (ends with .3gp) :

 http://daily3gp.com/vids/747.3gp http://daily3gp/www/vids/juggling_while_on_unicycle.3gp 

instead of .mp4 urls:

 video_url = "http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4"; 
+1
source

It is difficult to play video on the emulator because it needs a really fast computer. Try this link for the emulator. Perhaps you can get a discrete video view.

http://commonsware.com/misc/test2.3gp

Also in your real devices this link should work if your implementation is correct.

I assume that your video using the following link " http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4 is not suitable for secure streaming.

You must hint at this video or play other upcoming videos. I have not yet found another solution for playing with unverified videos.

This link may help.

getting PVMFErrContentInvalidForProgressivePlayback error when playing mp4 files on samsung devices

+1
source

Source: https://habr.com/ru/post/1346187/


All Articles