我试图用
Android的ExoPlayer在Android设备上播放DASH视频(
http://developer.android.com/guide/topics/media/exoplayer.html).文档非常非常差,我找不到DASH的一些简单的工作示例(如果有人做的话).在视频(
https://www.youtube.com/watch?v=6VjF638VObA#t=462)中,它看起来很简单,但实际上有很多未知的对象.我只想使用ExoPlayer库,而不使用他们的github演示,因为它非常复杂,我没有找到一种方法来添加我的测试URL,因为所有的样品都是从YouTube.
谢谢
解决方法
这是一个简单的破折号播放示例,它将从exoplayer-ui将您的流内容播放到SimpleExoPlayerView中.
将SimpleExoPlayerView添加到布局,并使用下面的代码
SimpleExoPlayerView exoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player_view); DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,Util.getUserAgent(this,"ExoPlayer")); Uri uri = Uri.parse("http://your_host/dash/stream.mpd"); DashMediaSource dashMediaSource = new DashMediaSource(uri,dataSourceFactory,new DefaultDashChunkSource.Factory(dataSourceFactory),null,null); BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter)); SimpleExoPlayer simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this,trackSelector); exoPlayerView.setPlayer(simpleExoPlayer); simpleExoPlayer.prepare(dashMediaSource);
还要添加依赖关系到你的build.gradle
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.0' compile 'com.google.android.exoplayer:exoplayer-dash:r2.4.0' compile 'com.google.android.exoplayer:exoplayer-hls:r2.4.0' compile 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.0' compile 'com.google.android.exoplayer:exoplayer-ui:r2.4.0'