Pinterest Grey Skold

How Pinterest Improves the Player on Android

Original post Improving the Player on Android

Article Summary

Pinterest's Android team faced a unique challenge: playing multiple videos simultaneously in a two-column grid without killing performance. Here's how they optimized ExoPlayer to handle it.

The Pinterest Engineering team shares their deep dive into video player optimization for Android. They tackled startup latency, memory management, and bandwidth issues specific to their mixed-media feed experience.

Key Takeaways

Critical Insight

By customizing ExoPlayer's DefaultLoadControl, DefaultTrackSelector, and building a smart player pool, Pinterest significantly reduced video startup latency while managing memory constraints.

Continue reading

What This Article Covers

Problem

Pinterest's video player was slow to start because ExoPlayer was doing extra work. It kept calculating aspect ratios and triggering layout callbacks even though the video dimensions were already known.

Solution

The team set aspect ratios upfront using AspectRatioFrameLayout.setAspectRatio(). They also overrode PlayerView.onContentAspectRatioChanged() with an empty implementation to stop unnecessary recalculations.

Impact

Removing this redundant UI rendering work reduced video startup latency at Pinterest. The fix didn't require any changes to ExoPlayer itself.

The article reveals a critical mistake most apps make with ExoPlayer's setForegroundMode flag and when you should actually use it.

This page summarizes “Improving the Player on Android” by Pinterest, published Nov 15, 2022. All credit for the original work goes to the authors.

Read the original on medium.com (opens in new tab)

AI tools for Android

Browse all AI tools →