@capgo/capacitor-jw-player

中文文档
8.0.62发布于 2026/11/09MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4.1万

Playes videos from jwplayer.com

原始使用文档
文档目录35 节
  1. ➡️ Get started for free
  2. Key features
  3. Key Features
  4. Documentation
  5. Compatibility
  6. Install
  7. Android
  8. Usage Examples
  9. Basic Setup and Playback
  10. Playback Controls
  11. Working with Playlists
  12. Audio and Caption Tracks
  13. Event Listeners
  14. API
  15. initialize(...)
  16. play(...)
  17. pause()
  18. resume()
  19. stop()
  20. seekTo(...)
  21. setVolume(...)
  22. getPosition()
  23. getState()
  24. setSpeed(...)
  25. setPlaylistIndex(...)
  26. loadPlaylist(...)
  27. loadPlaylistWithItems(...)
  28. getAudioTracks()
  29. getCurrentAudioTrack()
  30. setCurrentAudioTrack(...)
  31. getCaptions()
  32. getCurrentCaptions()
  33. setCurrentCaptions(...)
  34. currentPlaylist()
  35. Event Listeners

@capgo/capacitor-jw-player

Play videos and playlists from JW Player in your Capacitor app with the native JW Player SDKs on iOS and Android, in a fullscreen player.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-jw-player in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-jw-player to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-jw-player for Capacitor apps

Key features

  • Playback: initialize() with your license key, then play(), pause(), resume(), stop() and seekTo().
  • Playlists: loadPlaylist(), loadPlaylistWithItems() and setPlaylistIndex().
  • Tracks: audio track and captions selection.
  • Controls: setVolume(), setSpeed(), getPosition() and getState().
  • Platforms: iOS, Android and Web. Uses JWPlayerKit on iOS and the JW Player Android SDK. Web uses the JW Player web player.

Play videos from jwplayer.com with a fullscreen player interface. The plugin provides a comprehensive API for controlling JW Player playback, playlists, and tracks.

The latest version of the player require a min version of IOS 15

Key Features

  • Always fullscreen player
  • Supports both single videos and playlists
  • Complete control over playback (play, pause, seek, etc.)
  • Audio track selection
  • Caption/subtitle support
  • Event listeners for player state changes Playes videos from jwplayer.com

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/jw-player/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-jw-player` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-jw-player
npx cap sync

Android

Edit build.gradle in order for the plugin to work:

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://mvn.jwplayer.com/content/repositories/releases/'
        }
    }
}

Usage Examples

Basic Setup and Playback

import { JwPlayer } from '@capgo/capacitor-jw-player';

// Initialize the player with your license key
await JwPlayer.initialize({ 
  licenseKey: 'YOUR_JW_PLAYER_LICENSE_KEY' 
});

// Play a video
await JwPlayer.play({
  mediaUrl: 'https://example.com/video.mp4',
  mediaType: 'video' 
});

// Play a playlist
await JwPlayer.play({
  mediaUrl: 'https://cdn.jwplayer.com/v2/playlists/PLAYLIST_ID',
  mediaType: 'playlist'
});

Playback Controls

// Pause playback
await JwPlayer.pause();

// Resume playback
// Note: No need to call play() again with the URL, it resumes current content
await JwPlayer.play();

// Seek to a specific position (in seconds)
await JwPlayer.seekTo({ time: 30 });

// Set volume (0.0 to 1.0)
await JwPlayer.setVolume({ volume: 0.5 });

// Change playback speed
await JwPlayer.setSpeed({ speed: 1.5 });

// Stop and release the player
await JwPlayer.stop();

Working with Playlists

// Load a playlist by URL
await JwPlayer.loadPlaylist({ 
  playlistUrl: 'https://cdn.jwplayer.com/v2/playlists/PLAYLIST_ID' 
});

// Load a playlist with custom items
await JwPlayer.loadPlaylistWithItems({
  playlist: [
    { file: 'https://example.com/video1.mp4', title: 'Video 1' },
    { file: 'https://example.com/video2.mp4', title: 'Video 2' }
  ]
});

// Jump to a specific item in the playlist
await JwPlayer.setPlaylistIndex({ index: 2 });

// Get information about the current playlist
const playlistInfo = await JwPlayer.currentPlaylist();
console.log(playlistInfo.playlist);

Audio and Caption Tracks

// Get available audio tracks
const { tracks } = await JwPlayer.getAudioTracks();
console.log('Available audio tracks:', tracks);

// Get current audio track
const { index } = await JwPlayer.getCurrentAudioTrack();
console.log('Current audio track index:', index);

// Set audio track
await JwPlayer.setCurrentAudioTrack({ index: 1 });

// Get available captions
const { captions } = await JwPlayer.getCaptions();
console.log('Available captions:', captions);

// Set captions track (0 is usually "Off")
await JwPlayer.setCurrentCaptions({ index: 1 });

Event Listeners

import { JwPlayer } from '@capgo/capacitor-jw-player';

// Listen for player ready event
JwPlayer.addListener('ready', () => {
  console.log('Player is ready');
});

// Listen for playback state changes
JwPlayer.addListener('play', () => {
  console.log('Playback started');
});

JwPlayer.addListener('pause', (data) => {
  console.log('Playback paused, reason:', data.reason);
});

JwPlayer.addListener('complete', () => {
  console.log('Playback completed');
});

// Listen for time updates
JwPlayer.addListener('time', (data) => {
  console.log(`Position: ${data.position}, Duration: ${data.duration}`);
});

// Listen for playlist changes
JwPlayer.addListener('playlist', (data) => {
  console.log(`Playlist loaded with ${data.playlistSize} items`);
});

JwPlayer.addListener('playlistItem', (data) => {
  console.log(`Now playing item at index ${data.index}`);
});

// Listen for errors
JwPlayer.addListener('error', (data) => {
  console.error('Player error:', data.message);
});

// Clean up listeners when done
function cleanup() {
  JwPlayer.removeAllListeners();
}

API

initialize(...)

initialize(options: { licenseKey: string; playerUrl?: string; }) => Promise<void>

Initialize the JW Player

ParamTypeDescription
options{ licenseKey: string; playerUrl?: string; }- The options for the JW Player

play(...)

play(options: { mediaUrl: string; mediaType: 'video' | 'playlist'; autostart?: boolean; }) => Promise<void>

Play a video

ParamTypeDescription
options{ mediaUrl: string; mediaType: 'video' | 'playlist'; autostart?: boolean; }- The options for the JW Player

pause()

pause() => Promise<void>

Pause the currently playing media


resume()

resume() => Promise<void>

Resume the currently paused media


stop()

stop() => Promise<void>

Stop the currently playing media


seekTo(...)

seekTo(options: { time: number; }) => Promise<void>

Seek to a specific position in the currently playing media

ParamTypeDescription
options{ time: number; }- Options for seeking

setVolume(...)

setVolume(options: { volume: number; }) => Promise<void>

Set the volume level

ParamTypeDescription
options{ volume: number; }- Options for setting volume

getPosition()

getPosition() => Promise<{ position: number; }>

Get the current position in the media

Returns: Promise<{ position: number; }>


getState()

getState() => Promise<{ state: number; }>

Get the current player state

Returns: Promise<{ state: number; }>


setSpeed(...)

setSpeed(options: { speed: number; }) => Promise<void>

Set the playback speed

ParamTypeDescription
options{ speed: number; }- Options for setting speed

setPlaylistIndex(...)

setPlaylistIndex(options: { index: number; }) => Promise<void>

Set the current item in the playlist by index

ParamTypeDescription
options{ index: number; }- Options for setting playlist item

loadPlaylist(...)

loadPlaylist(options: { playlistUrl: string; }) => Promise<void>

Load a playlist

ParamTypeDescription
options{ playlistUrl: string; }- Options for loading a playlist

loadPlaylistWithItems(...)

loadPlaylistWithItems(options: { playlist: any[]; }) => Promise<void>

Load a playlist with items

ParamTypeDescription
options{ playlist: any[]; }- Options for loading a playlist

getAudioTracks()

getAudioTracks() => Promise<{ tracks: any[]; }>

Get available audio tracks

Returns: Promise<{ tracks: any[]; }>


getCurrentAudioTrack()

getCurrentAudioTrack() => Promise<{ index: number; }>

Get the current audio track

Returns: Promise<{ index: number; }>


setCurrentAudioTrack(...)

setCurrentAudioTrack(options: { index: number; }) => Promise<void>

Set the current audio track

ParamTypeDescription
options{ index: number; }- Options for setting audio track

getCaptions()

getCaptions() => Promise<{ captions: any[]; }>

Get the available captions/subtitles

Returns: Promise<{ captions: any[]; }>


getCurrentCaptions()

getCurrentCaptions() => Promise<{ index: number; }>

Get the current captions/subtitles track

Returns: Promise<{ index: number; }>


setCurrentCaptions(...)

setCurrentCaptions(options: { index: number; }) => Promise<void>

Set the current captions/subtitles track

ParamTypeDescription
options{ index: number; }- Options for setting captions track

currentPlaylist()

currentPlaylist() => Promise<any>

Get the current playlist

Returns: Promise<any>


Event Listeners

The plugin emits the following events that you can listen for:

EventDescriptionData
readyPlayer is ready to useNone
playPlayback has startedNone
pausePlayback is paused{ reason: number }
completePlayback of the current item is completeNone
timePlayback time has updated{ position: number, duration: number }
setupErrorError during setup{ code: number, message: string }
errorGeneral playback error{ code: number, message: string }
warningPlayer warning{ code: number, message: string }
playlistPlaylist has been loaded{ playlistSize: number }
playlistItemCurrent playlist item has changed{ index: number, file: string, title: string }
playerDismissedPlayer has been closed/dismissedNone

版本与发布记录

@capgo/capacitor-jw-player 共发布 93 个版本,首次发布于 2025/04/25;过去 12 个月发布了 60 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.62latest2026/11/09今天
8.0.612026/11/027 天前
8.0.602026/10/2613 天前
8.0.592026/10/1920 天前
8.0.582026/10/1525 天前
8.0.572026/10/1327 天前

关于 @capgo/capacitor-jw-player 的常见问题

@capgo/capacitor-jw-player 是什么?

Playes videos from jwplayer.com

如何安装 @capgo/capacitor-jw-player?

在项目目录运行 npm install @capgo/capacitor-jw-player,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-jw-player 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-jw-player 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-jw-player 可以商用吗?

@capgo/capacitor-jw-player 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-jw-player 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-jw-player 在 2026/10/09 – 2026/11/07 这 30 天内被下载 40,862 次,日均约 1,362 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-jw-player 还在维护吗?

最新版本 8.0.62 发布于 2026/11/09(今天);至今共发布 93 个版本,其中过去 12 个月发布了 60 个;首次发布于 2025/04/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。