JW Player
Native video playback with JW Player SDK integration
JW Player is a powerful video platform for delivering high-quality playback experiences. Median's JW Player Native Plugin integrates the JW Player iOS SDK and Android SDK into your app to provide native video playback with support for single videos, playlists, and adaptive streaming.
The plugin presents a full-screen native player and supports starting playback at a specific position. On iOS, Chromecast support is automatically initialized if configured.
App Configuration
The JW Player plugin requires a license key. Configure it in the App Studio, on the Native Plugins tab under "Advanced Mode":
{
"jwplayer": {
"active": true,
"licenseKey": "YOUR_JW_PLAYER_LICENSE_KEY"
}
}On iOS you can also configure Google Cast for Chromecast support by adding the appId:
{
"jwplayer": {
"active": true,
"licenseKey": "YOUR_JW_PLAYER_LICENSE_KEY",
"appId": "YOUR_CAST_APP_ID"
}
}
Android Auto-InitializationOn Android, the JW Player license key is automatically set from the server configuration. On iOS you must call
median.jwplayer.initialize()from JavaScript before playing content.
Implementation Guide
Initialize the JW Player SDK
Set your JW Player license key. On iOS this is required before playing any content. On Android this is optional if the key is already set in the server configuration.
↔️Median JavaScript Bridge
To initialize the JW Player SDK:
const result = await median.jwplayer.initialize({ licenseKey: 'YOUR_JW_PLAYER_LICENSE_KEY' }); // result object { success: true | false, error: { // present on failure only code: "NOT_INITIALIZED", message: "Invalid license key" } }
Parameters
| Parameter | Type | Description |
|---|---|---|
| licenseKey | string | Required. Your JW Player license key. |
Play a Video
Present a full-screen native player and begin video playback. You can provide a single video file, an array of video files (playlist), or a JW Player playlist URL.
↔️Median JavaScript Bridge
To play a video:
// Play a single video const result = await median.jwplayer.play({ file: 'https://example.com/video.mp4', startTime: 30 // optional: start at 30 seconds }); // Play a playlist const result = await median.jwplayer.play({ files: [ 'https://example.com/video1.mp4', 'https://example.com/video2.mp4' ] }); // Play from a JW Player playlist URL const result = await median.jwplayer.play({ playlistUrl: 'https://cdn.jwplayer.com/v2/playlists/abc123' });// Callback example median.jwplayer.play({ file: 'https://example.com/video.mp4', callback: function(result) { if (result.success) { console.log('Playback started'); } } });
Parameters
| Parameter | Type | Description |
|---|---|---|
| file | string | Optional. URL of a single video file. Takes priority over files. |
| files | string[] | Optional. Array of video URLs played as a playlist. |
| playlistUrl | string | Optional. URL to a JW Player JSON playlist feed. |
| startTime | number | Optional. Starting position in seconds (default: 0). |
At least one offile,files, orplaylistUrlmust be provided.
Return Values
The callback data differs between platforms:
iOS returns when the player has been configured:
{
success: true
}Android returns when the player is closed, including playback state:
{
success: true,
position: 120, // playback position in seconds at close time
state: "playing", // player state: "playing" | "paused" | "idle" | "complete"
file: "https://...", // URL of the current playlist item
isMute: false, // whether the player was muted
currentQuality: {}, // current video quality
currentAudioTrack: {}, // current audio track
currentCaptions: {} // current captions track
}Error Response
{
success: false,
error: {
code: "NOT_INITIALIZED" | "INTERNAL_ERROR",
message: "..."
}
}Chromecast Support (iOS)
On iOS, Chromecast support is automatically initialized at app launch when the appId is configured in the server configuration. No additional JavaScript calls are required.
To enable Chromecast, add your Google Cast application ID to the JW Player configuration in the App Studio as shown in the App Configuration section above.
Updated 1 day ago