Skip to main content

JW Player Capacitor plugin

Embed JW Player for professional video streaming with ads and analytics support

Install

bun add @capgo/capacitor-jw-player bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-jw-player
  • pnpm add @capgo/capacitor-jw-player
  • yarn add @capgo/capacitor-jw-player

Guide

How to use JW Player in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

JW Player plugin preview QR code

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.

FAQ

JW Player plugin FAQ

How do I install the JW Player plugin in a Capacitor app?

Run "bun add @capgo/capacitor-jw-player" (or "npm install @capgo/capacitor-jw-player"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-jw-player" in your app code.

Does @capgo/capacitor-jw-player work with React, Vue and Angular?

Yes. JW Player is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-jw-player support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-jw-player free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-jw-player/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses JW Player without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship JW Player changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo