NickUnuchek
NickUnuchek

Reputation: 12897

How to get resolutiion of video stream by url *.m3u8

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

Upvotes: 0

Views: 1728

Answers (1)

betorcs
betorcs

Reputation: 2831

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

Upvotes: 1

Related Questions