Media Player
Play audio in the background with native notification controls — play, pause, and stop from the notification panel.
The Custom Media Player add-on lets your app play audio (music, podcasts, radio streams, or any media URL) in the background while showing a native media notification with playback controls. When a user starts audio through your website, the media continues playing even when the app is minimized, and the device's notification panel displays Play, Pause, and Stop buttons — just like Spotify, Apple Music, or any native audio app.
This is powered by the native media session APIs on both Android and iOS, so the controls integrate with the device's lock screen, notification shade, and any connected Bluetooth/headphone controls automatically.
When to use this plugin
Use the Custom Media Player when your app needs to play audio that should continue in the background. Common use cases include music or podcast players, live radio or audio streaming, guided meditation or workout audio, and language learning apps with audio playback. If your audio only needs to play while the user is actively viewing the page (e.g. a sound effect or short clip), you may not need this plugin — standard HTML5 <audio> will work.
Prerequisites: Import the WebToNative JavaScript bridge into your website before using any of the functions below. See the Getting Started guide.
Step 1 — Enable the Add-On in WebToNative
That's it for dashboard configuration — there are no additional settings to fill in. All playback control happens through JavaScript.
For step-by-step screenshots, see the Custom Media Player add-on guide.
JavaScript API Reference
The Media Player API has three functions: start playback, pause it, and stop it entirely.
Play Media
Starts audio playback from the provided URL and shows a native media notification with playback controls. The audio continues playing in the background when the app is minimized.
Parameters:
url
String
Yes
The URL of the audio file or stream to play. Supports MP3, AAC, HLS streams, and other standard audio formats.
imageUrl
String
No
URL of an image to display in the media notification (e.g. album art, podcast cover). If omitted, a default image is shown.
Pause Media
Pauses the currently playing audio. The media notification remains visible so the user can resume playback from the notification panel.
This function takes no parameters.
Stop Media
Stops the audio playback entirely and dismisses the media notification from the notification panel.
This function takes no parameters.
Pause vs. Stop:
pauseMedia()keeps the notification visible and the media session alive — the user can resume from the notification.stopMedia()ends the session entirely and removes the notification.
Typical Implementation Flow
Here's how a typical media player integration looks:
Example: Simple Audio Player UI
This example shows a minimal implementation with play, pause, and stop buttons wired to the bridge functions:
Implementation Checklist
WebToNative Dashboard
Your Website
Frequently Asked Questions
What audio formats are supported?
The media player supports any format that the device's native audio engine can handle. This includes MP3, AAC, M4A, WAV, OGG (Android), and HLS streams. For broadest compatibility, MP3 or AAC is recommended.
Does audio continue playing when the app is minimized?
Yes. That's the primary purpose of this plugin. Once playMedia() is called, audio continues in the background with a native notification showing playback controls.
What happens if the user taps the notification controls?
The native media session handles Play, Pause, and Stop actions from the notification panel automatically. You don't need to write any additional JavaScript to handle notification control taps — they work out of the box.
Can I show custom artwork in the notification?
Yes. Pass an imageUrl parameter to playMedia() with a URL to your cover art, album artwork, or podcast logo. If omitted, the notification shows a default image.
Do I need to call `stopMedia()` when switching tracks?
It's good practice to call stopMedia() before calling playMedia() with a new URL. This cleanly ends the previous session and starts a fresh one for the new track.
Does this work with live streams?
Yes. You can pass a streaming URL (e.g. an HLS stream or an Icecast/Shoutcast URL) to playMedia() and it will play as a live stream with notification controls.
Is this available on both Android and iOS?
Yes. The Custom Media Player add-on supports both platforms.
Feature for Android was taken live on 26/09/2023 Feature for iOS was taken live on 18/06/2025