【问题标题】:Exo player DASH Streaming exampleExo 播放器 DASH 流媒体示例
【发布时间】:2015-04-07 19:45:00
【问题描述】:

我正在尝试使用来自 Google (http://developer.android.com/guide/topics/media/exoplayer.html) 的 ExoPlayer 在 Android 设备上播放 DASH 视频。文档非常非常差,我找不到 使用 DASH 的一些最简单的工作示例(如果有人这样做的话)。在视频 (https://www.youtube.com/watch?v=6VjF638VObA#t=462) 中,它看起来很简单,但实际上有很多未知物体。我只想使用 ExoPlayer 库而不使用他们的 github 演示,因为它非常复杂,而且我没有找到添加测试 URL 的方法,因为所有示例都来自 YouTube。

谢谢

【问题讨论】:

  • 哈哈..正是..文档很差。很多可用的功能,但没有记录所有的东西
  • exoplayer自己自适应吗?还是我们需要编写额外的代码?

标签: android video media-player exoplayer


【解决方案1】:

这是一个简单的破折号播放示例,它将把您的流内容从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'

【讨论】:

  • ExoPlayer 中 Dash MediaSource 的用法写得对,但我认为你不需要在 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-ui:r2.4.0'
  • @BawenderYandra 我这里有东西stackoverflow.com/questions/48920678/… 请检查。我是新手
  • @alijandro 你能再发一份 2.9.4 的 ocde 吗?
  • 我尝试了您的解决方案,但出现以下错误 ~> Source error.com.google.android.exoplayer2.ParserException: org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT ��� ��� ftypisom������...@3:25 in java.io.InputStreamReader@8bd3c66)
【解决方案2】:

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

我已经尝试在这里解释确切的步骤https://stackoverflow.com/a/29722423/4805417

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 2012-03-19
    相关资源
    最近更新 更多