# Native Media Player 5

## Warning: Unity 2022 and below are <mark style="color:red;">incompatible</mark> with <mark style="color:purple;">Android SDK 35+</mark>. Upgrade to <mark style="color:red;">Unity 6.1.3f</mark> or newer to ensure proper support.

Starting with <mark style="color:orange;">**Android SDK 35**</mark>, background audio is <mark style="color:orange;">**no longer possible using the legacy library (Media2)**</mark> due to <mark style="color:orange;">**new background execution restrictions**</mark><mark style="color:red;">.</mark> As a result, I had to <mark style="color:orange;">**completely rewrite the plugin using Media3**</mark>, which requires <mark style="color:orange;">**JDK 17 or higher**</mark> — meaning it's only supported in <mark style="color:orange;">**Unity 6 or later**</mark>.

{% embed url="<https://docs.unity3d.com/6000.1/Documentation/Manual/android-supported-dependency-versions.html>" %}

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

<table><thead><tr><th width="159.99993896484375">Android SDK / NMP</th><th width="194.9998779296875">Library Used</th><th>What happened</th></tr></thead><tbody><tr><td>SDK 33 / NMP 3</td><td>☑ ExoPlayer (Media2)</td><td>-</td></tr><tr><td>SDK 34 / NMP 3</td><td>✖ ExoPlayer (Media2)</td><td>SDK 34 requires background services to be configured with specific flags, but ExoPlayer's background service—managed by <code>PlayerNotificationManager</code>—does not expose methods to set these flags.</td></tr><tr><td>SDK 34 / NMP 4</td><td>☑ Custom Media Player (Media2)</td><td>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.</td></tr><tr><td>SDK 35 / NMP 4</td><td>✖ Custom Media Player (Media2)</td><td>SDK 35 no longer supports <code>MediaBrowserService</code> from the Media2 library, and Google has officially mandated migration to Media3.</td></tr><tr><td>SDK 35 / NMP 5</td><td>☑ ExoPlayer (Media3)</td><td>The good news is that Unity 6 supports Java 17, allowing Media3 integration — but projects must be upgraded to Unity 6 or later.</td></tr></tbody></table>

***

<figure><img src="https://1872171189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIwfDdduYNmq0pGIJU1RT%2Fuploads%2FufyvruNabdJfbztT2e8V%2Fimage.png?alt=media&#x26;token=e2f3d164-c37c-49ce-a643-d427c821ab44" alt=""><figcaption></figcaption></figure>

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.
