简体   繁体   English

从服务器android播放mp4视频

[英]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. 我想以流模式从服务器播放mp4格式和4-5Mb大小的视频。我使用的是sdk 2.3版,在模拟器上它只能发出声音,而不能发出任何图片。

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. 我还在设备Samsung(android sdk ver 2.1)和LG optimus(android sdk ver 2.2)上进行了测试,仅收到“无法播放视频:抱歉,此视频不适用于流式传输到此设备”消息。 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(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());
             }

    }

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 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. 我认为您的视频使用以下链接“ http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4不适合安全流式传输。

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 在三星设备上播放mp4文件时收到PVMFErrContentInvalidForProgressivePlayback错误

You may try these urls (ends with .3gp) : 您可以尝试以下网址(以.3gp结尾)

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

instead of .mp4 urls: 而不是.mp4网址:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM