简体   繁体   中英

Android Live Video Stream Not Playing

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

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.

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?

This problem seems to be common on a few Samsung devices. Did you check what Logcat shows?

I had the same problem with a Galaxy Tab 4, I ended up using Vitamio's library for video streaming. It's not been supported for some time now, but pretty easy to use and for basic customization

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

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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