Android的实时视频流不玩 [英] Android Live Video Stream Not Playing

查看:155
本文介绍了Android的实时视频流不玩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在流RTSP实时输入这样:

I am trying to stream a live feed in rtsp as such:

                       String uri = "rtsp://54.213.167.253:5544/63a1203d-4e12-438e-86ec-f447fa90cfd7";
                       Uri uri_add = Uri.withAppendedPath(MediaStore.Video.Media.INTERNAL_CONTENT_URI, "1");
                       videoView.setVideoURI(uri_add.parse(uri));
                       mediaController = new MediaController(_context);
                       videoView.setMediaController(mediaController);
                       videoView.requestFocus();
                       videoView.start();

这适用于一个HTC,我已经与索尼公司进行测试,与LG设备,但不会对银河S6或任何三星设备工作。我已经研究了编码兼容性和H.264是我流的是EN $ C $的CD,这应该在我所有的设备上运行。我运行Android诉这些设备上的5.0.2和5.1.1并没有对这个问题的软件之间没有相关性。也就是说,在GalaxyS6运行5.0.2是不是在玩视频同时运行HTC是5.0.2播放视频。我完全失去了作为可能是什么不能播放视频的消息,我得到的原因。

This works on an HTC, Sony, and LG device that I have tested with, however does not work on the Galaxy S6 or any Samsung device. I have researched the encoding compatibilities and h.264 is what my stream is encoded, which should work on all the devices I have. I am running Android v. 5.0.2 and 5.1.1 on these devices and there is no correlation between software to the issue. That is to say, the GalaxyS6 running 5.0.2 is not playing video while a HTC running 5.0.2 is playing video. I am completely lost as to what could be the cause of the "Can't Play Video" message that I get.

我看了所有的文章和帖子的人有关于流媒体视频直播,并试图实现他们在我的code,但是我每次运行到同样的问题。我是pretty肯定没有错与code,否则它不会在任何设备上在所有工作。任何人有任何想法可能是导致此?为什么?

I have read all the articles and posts people have about streaming live video and attempted to implement them in my code, however I run in to the same issue each time. I am pretty sure there is nothing wrong with the code, else it would not work at all on any device. Anyone have any ideas what could be causing this and why?

推荐答案

使用这个类。这是三星的设备也在运行。

Use this class. This is running on Samsung devices also.

private ProgressDialog progressDialog;
    VideoView videoView;
    private myAsync sync;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);

        String videourl = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
        videoView = (VideoView) findViewById(R.id.video_view);
        progressDialog = ProgressDialog.show(CustomizeProgressDialogActivity.this, "",
                "Buffering video...", true);
        progressDialog.setCancelable(false);
        // progressDialog.dismiss();
        MediaController mediaController = new MediaController(CustomizeProgressDialogActivity.this);
        mediaController.setAnchorView(videoView);

        Uri video = Uri.parse(videourl);// insert video url
        videoView.setMediaController(mediaController);

        videoView.setVideoURI(video);
        videoView.requestFocus();

        sync = new myAsync();
        sync.execute();
        // PlayVideo();
    }


    private class myAsync extends AsyncTask<Void, Integer, Void> {

        int duration = 0;
        int current = 0;

        @Override
        protected Void doInBackground(Void... params) {

            videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

                public void onPrepared(MediaPlayer mp) {
                    progressDialog.dismiss();
                    videoView.start();
                    duration = videoView.getDuration();
                }
            });

            do {


                current = videoView.getCurrentPosition();
                System.out.println("duration - " + duration + " current- "
                        + current);



                if (sync.isCancelled())
                    break;

            }

            while (current != duration || current == 0);

            return null;
        }

    }

这篇关于Android的实时视频流不玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆