改变 Exo 播放器的比特率

Changing bitrate of Exo Player

这个问题可能已经被问过很多次了。我到处搜索但找不到正确的答案。我在我的项目中使用 ExoPlayer 来播放 HLS 视频。

我想让用户选择 select 视频带宽。 YouTube does.Any 想出如何使用 ExoPlayer 实现这一点?

来自 ExoPlayer 问题跟踪器:

ExoPlayer currently selects the first variant listed in the master playlist. If I remember correctly, this is what Apple recommends/specifies as correct client behavior. If you want to start in the lowest quality, you should technically have your server generate the master playlist with the lowest quality listed first.

The above aside, we do agree that it makes more sense for the client to make the initial variant selection locally, as opposed to the recommended behavior. We'll be moving HLS over to use FormatEvaluator in ExoPlayer V2, which will give more control over the initial selection (and over the adaptive algorithm in general).

作为解决方案,这条评论:

Have a look at AdaptiveTrackSelection.Factory. Its parameters may provide enough customization for your case.

我认为这应该会为您提供所需的答案,或者会引导您朝着正确的方向前进。

请注意,您必须提供 较低质量的流才能使用它。 如果您只有高清视频,ExoPlayer 无法对视频进行下采样,这不是它的工作,也不是它的目的。 ExoPlayer 只能在提供多种分辨率的视频之间同步和平滑过渡。