Apps

What is Media3 / ExoPlayer

What it is

Google's library for playing audio and video in Android apps: background playback, a notification with buttons, lock-screen controls.

How we use it

The OshaPlay player is built on Media3: background playback and the playback service. Our own C++ output to a USB DAC plugs into Media3 as a custom AudioSink, which is why a track reaches the DAC bit for bit.

Where it helps a business

  • An app has to play music, audiobooks or video in the background, with controls in the notification and on the lock screen.
  • You need non-standard audio output, for example straight to an external device.

How we use it

The OshaPlay player is built on Media3 (ExoPlayer and MediaSessionService): background playback of FLAC, m4a, MP3 and Opus, a notification and lock-screen controls. Our own C++ output to a USB DAC plugs into Media3 as a custom AudioSink, which is why a track reaches the DAC bit for bit, bypassing the system mixer. Audiobook speed from 0.8ร— to 2.5ร— works in direct output too.

Common problems

  • The phone's shell puts the player to sleep. On Huawei with the screen off, EMUI froze playback for seconds; the cause was found from phone reports.
  • While the player holds the DAC, Android cannot see it. Notifications and calls sound from the phone's speaker; after a minute of pause the DAC is handed back to the system automatically.

When you do not need it

If audio means a couple of short interface sounds, a full player is unnecessary.

โ† All terms

Need a website, a bot or automation?

Terms explained โ€” now let's get to work: tell us about the task and we'll turn it into a clear work plan.