Getting Started
Ce contenu n'est pas encore disponible dans votre langue.
-
Install the plugin
Fenêtre de terminal npm i @capgo/capacitor-mux-playerFenêtre de terminal pnpm add @capgo/capacitor-mux-playerFenêtre de terminal yarn add @capgo/capacitor-mux-playerFenêtre de terminal bun add @capgo/capacitor-mux-player -
Sync native projects
Fenêtre de terminal npx cap syncFenêtre de terminal pnpm cap syncFenêtre de terminal yarn cap syncFenêtre de terminal bunx cap sync
iOS preparation
- Open the Xcode workspace under
ios/App/. - Add the Swift package
https://github.com/muxinc/mux-player-swiftto your app target so theMuxPlayerSwiftmodule is available. - Ensure the deployment target is iOS 15+ and rebuild.
Android preparation
The Gradle module ships with the correct repositories and dependencies. If you use a custom corporate proxy, allow requests to https://muxinc.jfrog.io/artifactory/default-maven-release-local.
Launch the player
import { MuxPlayer } from '@capgo/capacitor-mux-player';
await MuxPlayer.play({ playbackId: 'your-playback-id', environmentKey: 'your-mux-data-key', title: 'Launch Announcement', subtitle: 'Filmed live at Capgo HQ', poster: 'https://stream.example.com/poster.jpg',});Listen to player events
const readyHandle = await MuxPlayer.addListener('ready', ({ playerName }) => { console.log('Mux player ready', playerName);});
const errorHandle = await MuxPlayer.addListener('error', ({ message }) => { console.error('Mux player error:', message);});
// Clean up after dismissing the playerconst dismissPlayer = async () => { await MuxPlayer.dismiss(); await readyHandle.remove(); await errorHandle.remove();};Token-based playback
await MuxPlayer.play({ playbackId: 'signed-playback-id', playbackToken: signedPlaybackToken, drmToken: signedDrmToken, // Optional if you enabled DRM policies autoPlay: true, startTime: 120, // begin at 2 minutes});React to player lifecycle
const { active } = await MuxPlayer.isActive();if (active) { console.log('Player currently visible');}
// Remove all listener registrations when unmountingawait MuxPlayer.removeAllListeners();Tips
- Generate signed playback and DRM tokens on your backend using the Mux signing keys.
- Pass a
playerNameto separate analytics when running multiple players in your app. - Combine with
enableSmartCacheto improve offline resilience on supported platforms.