Bla*_*jco 16 video android media-player exoplayer
我正在尝试使用Google 的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.
谢谢
ali*_*dro 11
下面是一个简单的破折号玩例如,将播放流的内容为SimpleExoPlayerView从exoplayer-ui.
添加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);
Run Code Online (Sandbox Code Playgroud)
还要将依赖项添加到您的 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'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17251 次 |
| 最近记录: |