Native Media Player 5

Warning: Unity 2022 and below are incompatible with Android SDK 35+. Upgrade to Unity 6 or newer to ensure proper support.

Starting with Android SDK 35, background audio is no longer possible using the legacy library (Media2) due to new background execution restrictions. As a result, I had to completely rewrite the plugin using Media3, which requires JDK 17 or higher — meaning it's only supported in Unity 6 or later.

Here’s a brief overview of the recent changes in Android SDK and its media libraries.

Android SDK / NMP
Library Used
What happened

SDK 33 / NMP 3

☑ ExoPlayer (Media2)

-

SDK 34 / NMP 3

✖ ExoPlayer (Media2)

SDK 34 requires background services to be configured with specific flags, but ExoPlayer's background service—managed by PlayerNotificationManager—does not expose methods to set these flags.

SDK 34 / NMP 4

☑ Custom Media Player (Media2)

As a result, I built a custom media player based on the Media2 library that mimics ExoPlayer’s functionality while exposing the required flag setters for background service support.

SDK 35 / NMP 4

✖ Custom Media Player (Media2)

SDK 35 no longer supports MediaBrowserService from the Media2 library, and Google has officially mandated migration to Media3.

SDK 35 / NMP 5

☑ ExoPlayer (Media3)

The good news is that Unity 6 supports Java 17, allowing Media3 integration — but projects must be upgraded to Unity 6 or later.


Welcome to the Native Media Player documentation! This powerful and versatile media player is designed to provide a seamless audio experience across both Android and iOS platforms. Built on three years of Unity audio plugin development, the Native Media Player offers a wide range of features to enhance your application's audio capabilities.

Highlights

  • Easy to Use: User-friendly interface and straightforward setup.

  • Cross-Platform API: Supports both Android and iOS, providing a consistent experience across devices.

  • Proven Technology: Based on three years of experience in Unity audio plugin development.

  • Drag and Drop Components: Simplifies the integration process with easy-to-use components.

  • Local and Remote Audio Support: Play audio from local (StreamingAssets, PersistantDataPath) and remote sources.

  • Background Playback: Continues to play audio when the app goes into the background.

  • Background Controls: Manage audio playback while the app is in the background.

  • Automatic Metadata Retrieval: Automatically fetches media metadata from the audio source.

  • Custom Metadata: Create and manage custom media metadata.

  • Modular Remote Action Buttons: Fully customizable remote action buttons for playback control.

  • Modular Event Listeners: Fully customizable event listeners to handle various playback events.

  • Unity Editor Test Mode: Test your audio setup directly within the Unity Editor.

Playback Features

  • Basic Controls: Play, Pause, Stop, Next, Previous, Fast-forward, Rewind, Seek-To.

  • Playback Modes: Repeat, Loop, Shuffle.

  • User Interface: Volume bar, Seek bar.

Native Event Listeners

  • Player States: Player Idle, Player Buffering, Player Ready, Player Ended, Player Error.

  • Metadata Updates: Metadata Changed, IsPlaying Changed, IsLoading Changed.

Platform Support

  • iOS: Supports 64-bit devices running iOS 11.0 and above.

  • Android: Supports both 32-bit and 64-bit devices running Android 7.0 and above.

Last updated