Exoplayer播放Android的M3U8文件 [英] Exoplayer playing m3u8 files Android

查看:1668
本文介绍了Exoplayer播放Android的M3U8文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用 videoview和mediaplayer 播放m3u8文件的多种方式后,我决定放弃.每次播放m3u8文件时,我只会听到声音.(请不要写出堆栈溢出的URL回答我的问题.我把它们都变红了) 经过四处询问,终于知道 exoplayer 可能是我要找的人.但是exoplayer似乎是新手,我找不到任何合适的教程.据说我本人是新手,关于跟踪器和blabla的所有讨论对我来说似乎太复杂了.我只希望能够在我的应用程序中打开中来自不同URL的所有m3u8文件,而无需将它们传递给vlc或任何外部意图.

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.

出于记录目的,我使用KitKat及更高版本.因此exoplayer应该是可以实现的.

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

因此,我迫切需要的是一个简单的教程,该教程介绍了如何使用exoplayer播放m3u8文件或其他任何显示视频并播放音频的方式,只是其中之一.请不要将我链接到 google dev 上的exoplayer页面.我也去过那里.

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.

先谢谢您了:)

推荐答案

在Android 4.1+上,您可以使用此库 https://github.com/brianwernick/ExoMedia/.自述页面上提到的示例应该足以使您入门.我已经复制了该代码段,并进行了一些补充/修改.

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

这篇关于Exoplayer播放Android的M3U8文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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