Exo播放器DASH Streaming示例

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

下面是一个简单的破折号玩例如,将播放流的内容为SimpleExoPlayerViewexoplayer-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)


小智 -2

实际上,将测试 URL 添加到 Github 上提供的 ExoPlayer 演示应用程序非常简单。

我试图在这里解释确切的步骤/sf/answers/2080569641/