<img src="https://img.shields.io/badge/%20-ENTERPRISE-%23B10031" style="float:left"/><br /> <img src="https://img.shields.io/badge/Android-V4-009727?logo=android" style="float:left"/><br />

If you have a media application that plays video podcasts, enabling Background Audio allows your viewers to play the podcast audio while they are no longer actively using your app or have locked their device.

<br /> <hr />

## Lifecycle

The following diagram illustrates a lifecycle for Background Audio.

1144




  1. From the `Activity`, get a reference to the `JWPlayer`.

  2. From the `Activity`, instantiate `MediaServiceController`.

  3. Once playback begins, call the `bindService()` on the `MediaServiceController` to show the Media notification.

  4. From the `Activity`'s `onDestroy()`, call `unbindService()` on the `MediaServiceController` to teardown the Service and Notification. It is important to call `unbindService()` to prevent any memory leaks.

<br /> <hr />

## Implementation

  1. In the **AndroidManifest.xml**, add the `MediaService` and `MediaButtonReceiver`.


  1. Use `MediaServiceController.Builder()` to create an instance of `MediaServiceController`. Provide the method the `Activity` and the `JWPlayer` that the service should control.<br />The `MediaServiceController` class offers a convenient API to bind and unbind the `MediaService` as well as to update the `ServiceMediaApi` with a new player.


  1. Call `bindService()` to show the Media notification or `unbindService()` to teardown the Service and Notification.

<br /> <hr />

## Customization

By using the `MediaServiceController.Builder()`, you can specify your own implementations of `ServiceMediaApi` or `NotificationHelper` to provide the type of functionality you want for your media application. Each class is explained below.

ClassDescription
**NotificationHelper**Responsible for defining the Notification styling and details<br /><br />If you want to customize the behavior of this class, you can either use the `Builder()` provided by JWP or try extending it to add or override the functionality you want.
**ServiceMediaApi**Class responsible for defining the APIs available to the Notification<br /><br />If you want to customize the behavior of this class, it is recommended that you extend it and add or override the functionality you want.

<br />

(Script tags will be stripped)