Best Practices for Video Playback in Android
Article Summary
Saurabh Arora from Viki reveals the video playback mistakes that shock users and kill engagement. Most Android apps get at least 3 of these wrong.
The Viki engineering team has spent years perfecting video playback for millions of global viewers. This article distills their hard-won lessons into 7 actionable practices that separate great video apps from mediocre ones.
Key Takeaways
- Request AUDIOFOCUS_GAIN and implement OnAudioFocusChangeListener to prevent audio conflicts
- Listen for ACTION_AUDIO_BECOMING_NOISY broadcast to pause when headphones unplug
- Use MediaSession framework to support headphone controls and third-party controllers
- Switch to onStop (not onPause) for split-screen mode support
- Implement SCREEN_ORIENTATION_SENSOR_LANDSCAPE for flexible device positioning
Android's built-in frameworks handle most video playback UX challenges, but only if you know which APIs to call and when to call them.
About This Article
Video playback apps need to keep the screen on during playback. Many Android developers either skip this feature or get it wrong.
Saurabh Arora suggests calling setKeepScreenOn(true) when playback starts and setKeepScreenOn(false) when it ends. This uses Android's built-in screen management API.
Two lines of code solve a real problem. Users won't see their screen dim unexpectedly, and Viki's millions of viewers get uninterrupted playback.