Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exoplayer playing m3u8 files Android

After trying multiple ways of playing m3u8 files using videoview and mediaplayer I decided to give up. Everytime i play the m3u8 file I only hear the voice.(please dont write urls from stack overflow answering my question. I' ve red them all ) Been asking around ,finally got to know that exoplayer maybe is the one I'm looking for. However exoplayer seems to be a newbie and I can'n find any proper tutorial. That been said Im myself a newbie and all talks about tracker and blabla seem just too complicated for me. I only want to be able to open all my m3u8 files from different urls in my app without passing them to vlc or any external intents.

For the record I use KitKat and above. So exoplayer should be implementable.

So what Im desperatly asking for is a simple tutorial in how I can play my m3u8 files using exoplayer or anyother way that shows the video and play the audio and NOT just one of them. Please dont link me to the exoplayer page on google dev. Ive been there too.

Thanks in advance :)

like image 973
Payam30 Avatar asked Jul 14 '15 22:07

Payam30


People also ask

Does ExoPlayer support m3u8?

m3u8 video file from server using FFMPEG. Exoplayer does not support mp4 file format for adaptive streaming but you can choose mp4 like format for auto streaming.

How do I play m3u8 files on Android?

Even currently android builtin media player is able to play live urls inside an m3u8. Basically m3u8 is nothing else but text file to android. So you have to make m3u parser. If you are just looking for application, you can try and iptv which is free to use.

How do I play m3u8 streams?

How to open an M3U8 file. You can open an M3U8 file and play the playlist it contains in many media players, including Microsoft Windows Media Player (Windows) and VideoLAN VLC media player (multiplatform).


1 Answers

On Android 4.1+, you can use this library https://github.com/brianwernick/ExoMedia/ . The example mentioned on the Read-me page should be sufficient to get you started. I have reproduced that code snippet with a few additions/modifications.

            private void setupVideoView() {
                EMVideoView emVideoView = (EMVideoView)findViewById(R.id.video_play_activity_video_view);
                emVideoView.setOnPreparedListener(this);

                //Enter your m3u8 URL below
                emVideoView.setVideoURI(Uri.parse("http://SOMESERVER/playlist.m3u8"));
            }

            @Override
            public void onPrepared(MediaPlayer mp) {
                //Starts the video playback as soon as it is ready
                emVideoView.start();
            }

            @Override
            public void onPause() {
                super.onPause();
                //Pause Video Playback
                emVideoView.pause();
            }
like image 193
jeff-thexman Avatar answered Oct 13 '22 00:10

jeff-thexman