开发者

Play Mp4 video from server android

I want to play video of mp4 format and size 4-5Mb from server in streaming mode.I am using sdk version 2.3,on emulator it gives only sound but not any picture.

I also tested it on devices Samsung(android sdk ver 2.1) and LG optimus(android sdk ver 2.2) and only get "cannot play video:sorry this video is not valid for streaming to this device" message. I have searched on this but not getting any solution, if anybody have 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(videoV开发者_Go百科iew);
                // 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());
             }

    }


You may 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";


On emulator it is difficult to get video played, because it needs really fast computer. Try this link for emulator. Maybe you can get some discrete video view.

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

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

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

You should hint that video or play other hinted videos. I couldn't find any other solution for playing unhinted videos yet.

This link may help.

getting PVMFErrContentInvalidForProgressivePlayback error while playing mp4 files on samsung devices

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜