从 Android 服务器播放 Mp4 视频

发布于 2024-10-28 09:27:36 字数 1767 浏览 2 评论 0原文

我想以流模式从服务器播放 mp4 格式和大小 4-5Mb 的视频。我使用的是 sdk 版本 2.3,在模拟器上 只提供声音但不提供任何图像。

我还在 Samsung(android sdk ver 2.1) 和 LG optimus(android sdk ver 2.2) 设备上进行了测试 并且只收到“无法播放视频:抱歉,该视频对于流式传输到此设备无效”消息。 我已经搜索过这个问题,但没有得到任何解决方案,如果有人有任何解决方案,请帮助我。提前致谢。

这是我的代码:

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());
             }

    }

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(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());
             }

    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪都笑了 2024-11-04 09:27:36

您可以尝试使用这些网址(以.3gp结尾)

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

而不是.mp4网址:

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

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";
决绝 2024-11-04 09:27:36

在模拟器上很难播放视频,因为它需要非常快的计算机。尝试使用模拟器这个链接。也许您可以获得一些离散的视频视图。

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

同样在您的真实设备中此链接如果您的实施正确,应该可以工作。

我假设您的视频使用以下链接
http://www.letumobi.com/videouploads/cd0a4170 -1fb2-4fba-b17c-b5d70b2cd2e7.mp4
不适合安全流式传输。

您应该提示该视频或播放其他提示视频。我还找不到任何其他解决方案来播放无提示的视频。

此链接可能有帮助。

在三星设备上播放 mp4 文件时出现 PVMFErrContentInvalidForProgressivePlayback 错误

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文