Using @capgo/capacitor-jw-player
Playes videos from jwplayer.com.
Install
bun add @capgo/capacitor-jw-player
bunx cap sync
bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.
Import
import { JwPlayer } from '@capgo/capacitor-jw-player';
API at a glance
| Method | Description |
|---|---|
initialize |
Initialize the JW Player. |
play |
Play a video. |
pause |
Pause the currently playing media. |
resume |
Resume the currently paused media. |
stop |
Stop the currently playing media. |
seekTo |
Seek to a specific position in the currently playing media. |
setVolume |
Set the volume level. |
getPosition |
Get the current position in the media. |
getState |
Get the current player state. |
setSpeed |
Set the playback speed. |
setPlaylistIndex |
Set the current item in the playlist by index. |
loadPlaylist |
Load a playlist. |
loadPlaylistWithItems |
Load a playlist with items. |
getAudioTracks |
Get available audio tracks. |
getCurrentAudioTrack |
Get the current audio track. |
setCurrentAudioTrack |
Set the current audio track. |
getCaptions |
Get the available captions/subtitles. |
getCurrentCaptions |
Get the current captions/subtitles track. |
setCurrentCaptions |
Set the current captions/subtitles track. |
currentPlaylist |
Get the current playlist. |
Examples
initialize()
Initialize the JW Player.
import { JwPlayer } from '@capgo/capacitor-jw-player';
await JwPlayer.initialize({ licenseKey: 'license-key-123' });
play()
Play a video.
import { JwPlayer } from '@capgo/capacitor-jw-player';
await JwPlayer.play({
mediaUrl: 'https://example.com',
mediaType: 'video',
});
pause()
Pause the currently playing media.
import { JwPlayer } from '@capgo/capacitor-jw-player';
await JwPlayer.pause();
resume()
Resume the currently paused media.
import { JwPlayer } from '@capgo/capacitor-jw-player';
await JwPlayer.resume();
stop()
Stop the currently playing media.
import { JwPlayer } from '@capgo/capacitor-jw-player';
await JwPlayer.stop();
seekTo()
Seek to a specific position in the currently playing media.
import { JwPlayer } from '@capgo/capacitor-jw-player';
await JwPlayer.seekTo({ time: 10 });
The table above lists the 20 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.
Full reference
Keep going from Using @capgo/capacitor-jw-player
If you are using Using @capgo/capacitor-jw-player to plan native plugin work, connect it with @capgo/capacitor-jw-player for the implementation detail in @capgo/capacitor-jw-player, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.