0

I open stream video by url *.m3u8 in Video View
Display of my device is 800x480
but if video stream resolution is 1024x768 video stops playing and can be crash of app.

How to get resolutiion of video steam by url *.m3u8? OR How to resize video stream?

mVideoView.setMediaController(new MediaController(OpenStream.this));
                        mVideoView.setVideoURI(Uri.parse(url));
                        mVideoView.requestFocus();
                        mVideoView.setOnPreparedListener(new OnPreparedListener() {


                                public void onPrepared(MediaPlayer mp) {
                                    mp.start();
                                }
                            });

Error:

01-29 18:21:12.831: E/MediaPlayer(23281): error (1, -2147483648)
01-29 18:21:12.831: V/MediaPlayer(23281): callback application
01-29 18:21:12.831: V/MediaPlayer(23281): back from callback
01-29 18:21:12.831: E/MediaPlayer(23281): Error (1,-2147483648)
01-29 18:21:12.831: D/VideoView(23281): Error: 1,-2147483648
NickUnuchek
  • 11,794
  • 12
  • 98
  • 138
  • You can get the video width/height from MediaPlayer, after that you can set them to VideoView SurfaceHolder. – betorcs Jan 29 '14 at 13:09

1 Answers1

1

Try this

            mVideoView.setMediaController(new MediaController(OpenStream.this));
                    mVideoView.setVideoURI(Uri.parse(url));
                    mVideoView.requestFocus();
                    mVideoView.setOnPreparedListener(new OnPreparedListener() {


                            public void onPrepared(MediaPlayer mp) {
                                int w = mp.getVideoWidth();
                                int h = mp.getVideoHeight();
                                SurfaceHolder holder = mVideoView.getHolder();
                                holder.setFixedSize(w, h); // Or setup a proportional sizes
                                mp.start();
                            }
                        });
betorcs
  • 2,771
  • 22
  • 28
  • w and h return 0 and 0 – NickUnuchek Jan 29 '14 at 13:59
  • In your case i suppose you should use http://developer.android.com/reference/android/media/MediaPlayer.html#setOnVideoSizeChangedListener(android.media.MediaPlayer.OnVideoSizeChangedListener). I'd use MediaPlayer and SurfaceView instead of VideoView. I found a sample for http://software.intel.com/en-us/articles/android-mediaplayer-sample-code-walkthrough-on-intel-architecture – betorcs Jan 29 '14 at 14:11