Android Developers
Published in

Android Developers

Understanding MediaSession (Part 1/4)

Is MediaSession for me?

  1. Making sense of the complex media landscape
  2. How to use it for simple use cases
  3. How to use it for complex use cases

Examples of media playback apps

Let’s go through a few types of apps you might be building to see if MediaSession is needed.

Video game app

Video games often include music and sound effects to enhance the user’s experience, but, in this case, the user usually doesn’t have any expectation of being able to pause the music or skip to the next track, so there would be no need to use a MediaSession here.

Video player app

A video player may only play audio and video while the app is in the foreground, so it may not seem necessary to integrate with MediaSession. However, in order for your app to respond to media button events you would need to integrate with MediaSession.

Music player app

A music player app should absolutely integrate MediaSession. MediaSession provides hooks for playback control via media buttons on headphones, Android Wear, Android Auto, and Google Assistant. It might also benefit from utilizing a MediaBrowserService. By providing a MediaBrowserService, the app can allow users to use Android Auto, Wear, Assistant, and Bluetooth devices to navigate the media contents (without using the app’s UI).

Android Media Resources

--

--

Articles on modern tools and resources to help you build experiences that people love, faster and easier, across every Android device.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nazmul Idris (Naz)

Google SWE, entrepreneur, leader, designer, dancer, TaiChi'er, Yogi, racer, healer, storyteller. I ❤️ leadership, authenticity, empowerment, & lifelong learning