Android supprot HLS Adaptive Bitrate Streaming?



我尝试使用 HLS 自适应比特率流式处理

我制作变体播放列表:文件名为 test.m3u8

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=200000
low/low.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=311111
middle/middle.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=484444
high/high.m3u8

每个 m3u8 文件:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:6.040000,
#EXT-X-BYTERANGE:158484@0
http://myserver/hls/Test/low/low.ts
#EXTINF:4.200000,
#EXT-X-BYTERANGE:121824@158484
http://myserver/hls/Test/low/low.ts
#EXTINF:10.000000,
#EXT-X-BYTERANGE:286512@280308
http://myserver/hls/Test/low/low.ts
..........
#EXT-X-ENDLIST

我的文件夹结构 :

/hls/Test/test.m3u8
/hls/Test/low/low.m3u8
/hls/Test/middle/middle.m3u8
/hls/Test/high/high.m3u8

我的问题是:

iOS 设备调用此 URL( http://myserver/hls/Test/test.m3u8 (
视频播放工作。

安卓设备调用此网址( http://myserver/hls/Test/test.m3u8 (
视频无法播放。
但是,我调用网址( http://myserver/hls/Test/low/low.m3u8 (
视频播放工作。

安卓设备:三星银河注3

安卓客户端来源:

@Override   
protected void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    initUI();
    Uri uri = Uri.parse("http://myserver/hls/Test/test.m3u8");
    MediaController mc = new MediaController(this);
    video_videoView.setMediaController(mc);
    video_videoView.setVideoURI(uri);
    video_videoView.start();
}   
private void initUI() { 
    video_videoView = (VideoView) findViewById(R.id.video_videoView);
}   

安卓日志猫错误:

12-19 11:20:12.547: I/MediaPlayer(1704): path is null   
12-19 11:20:12.567: D/MediaPlayer(1704): setDataSource IOException happend :    
12-19 11:20:12.567: D/MediaPlayer(1704): java.io.FileNotFoundException: No content provider:   http://myserver/hls/Test/test.m3u8
12-19 11:20:12.567: D/MediaPlayer(1704): at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1053)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:907)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:834)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:978)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.widget.VideoView.openVideo(VideoView.java:338)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.widget.VideoView.access$2100(VideoView.java:71)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.widget.VideoView$7.surfaceCreated(VideoView.java:618)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.SurfaceView.updateWindow(SurfaceView.java:602)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.SurfaceView.access$000(SurfaceView.java:94)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:183)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:888)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2199)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6624)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:812)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.Choreographer.doCallbacks(Choreographer.java:612)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.Choreographer.doFrame(Choreographer.java:582)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:798)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.os.Handler.handleCallback(Handler.java:733)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.os.Handler.dispatchMessage(Handler.java:95)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.os.Looper.loop(Looper.java:146)
12-19 11:20:12.567: D/MediaPlayer(1704): at android.app.ActivityThread.main(ActivityThread.java:5602)
12-19 11:20:12.567: D/MediaPlayer(1704): at java.lang.reflect.Method.invokeNative(Native Method)
12-19 11:20:12.567: D/MediaPlayer(1704): at java.lang.reflect.Method.invoke(Method.java:515)
12-19 11:20:12.567: D/MediaPlayer(1704): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
12-19 11:20:12.567: D/MediaPlayer(1704): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
12-19 11:20:12.567: D/MediaPlayer(1704): at dalvik.system.NativeStart.main(Native Method)
12-19 11:20:12.567: D/MediaPlayer(1704): Couldn't open file on client side, trying server side  

请帮忙..

原生VideoView并不真正支持HLS流。使用 ExoPlayer 构建自定义视频播放器

在 Android 开发者控制台中提到:

"ExoPlayer支持MediaPlayer目前未提供的功能,包括HTTP上的动态自适应流(DASH(,SmoothStreaming和Common Encryption。它的设计易于自定义和扩展,允许将许多组件替换为自定义实现。因为ExoPlayer是一个包含在应用程序中的库,所以它可以很容易地与你的应用程序一起更新。

http://developer.android.com/guide/topics/media/exoplayer.html

此外,您可以搜索包装在ExoPlayer周围的库。

例:https://github.com/brianwernick/ExoMedia

相关内容

  • 没有找到相关文章

最新更新