改进安卓上的播放器
Grey Skold | (former Android Video Engineer) ; Lin Wang | Android Performance Engineer; Sheng Liu | Android Performance Engineer
Grey Skold |(前安卓视频工程师);Lin Wang | 安卓性能工程师;Sheng Liu | 安卓性能工程师
Pinterest Android App offers a rare experience with a mix of images and videos on a two-column grid. In order to maintain a performant video experience on Android devices, we focused on:
Pinterest安卓应用提供了一种罕见的体验,在两列网格上混合了图片和视频。为了在安卓设备上保持高性能的视频体验,我们专注于。
- Warming up
- 暖身
- Configurations
- 配置
- Pooling players
- 汇集球员
Warming Up
暖身
In order to reduce the startup latency, we establish a video network connection by sending a dummy HTTP HEAD request during the early application startup time. The same connection can be used to play future videos. This is done even before any video urls are returned from our server.
为了减少启动延迟,我们通过在应用程序早期启动时发送一个假的HTTP HEAD请求来建立视频网络连接。同样的连接可以用来播放未来的视频。这甚至是在任何视频尿液从我们的服务器返回之前完成的。
The same strategy also applies to UI rendering. We found Exoplayer tends to do lots of work after parsing the information from the video url. It:
同样的策略也适用于UI渲染。我们发现Exoplayer在解析了视频网址的信息后往往会做很多工作。它。
Since most of our videos’ aspect ratios are pre-determined, we can prevent the above work by:
由于我们大多数视频的长宽比是预先确定的,我们可以通过以下方式防止上述工作。
The latter prevents the player from trying to recalculate the aspect ratio.
后者可以防止播放器试图重新计算长宽比。
Configurations
配置
ExoPlayer provides us the setBufferDurationsMs() to customize various buffering durations used to delay playback until we have sufficient data. Since a majority of Pinterest’s media content is in short-form, we can use much shorter buffering durations which will result in less time waiting for data to load.
ExoPlayer为我们提供了setBufferDurationsMs()来定制各种缓冲时长,用于延迟播放,直到我们有足够的数据。由于Pinterest的大部分媒体内容都是短篇的,我们可以使用更短的缓冲时间,这将导致等待数据加载的时间减少。
By doing this, we saw a significant reduction in video startup latency. Although the rebuffer rate increases a bit, the overall video UX is still improved.
通过这样做,我们看到视频启动延迟明显减少。虽然重建率增加了一些,但整个视频用户体验仍然得到了改善。
DefaultTrackSelector
默认TrackSelector
Using the following two parameters, we could effe...