Media Player API
Control audio and video playback using the WebToNative JavaScript API. Play, pause, and manage media seamlessly in Android and iOS apps.
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.
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
Feature for Android was taken live on 26/09/2023 Feature for iOS was taken live on 18/06/2025
Last updated