Aller au contenu

Prise en main

GitHub

Vous pouvez utiliser notre configuration assistée par IA pour installer le plugin. Ajoutez les skills Capgo à votre outil d'IA avec la commande suivante :

Fenêtre de terminal
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Utilisez ensuite le prompt suivant :

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

Si vous préférez une installation manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à chaque plateforme ci-dessous :

Fenêtre de terminal
bun add @capgo/capacitor-mux-player
bunx cap sync
import { MuxPlayer } from '@capgo/capacitor-mux-player';
import { MuxPlayer } from '@capgo/capacitor-mux-player';
const { active } = await MuxPlayer.isActive();
if (active) return;
await MuxPlayer.play({
playbackId: 'YOUR_PLAYBACK_ID',
});

Passez le token de lecture généré par votre backend pour le DRM ou les politiques signées, comme documenté dans le README du plugin.

  • Lecteur unique: vérifier isActive() avant d'appeler play() à nouveau.
  • Ignorer le nettoyage: écoutez l'événement de fermeture si vous devez reprendre la vidéo WebView en ligne après.
  • Expiration des tokens: rafraîchissez les JWT signés côté serveur avant les sessions longues.

Lancer le Mux Player natif en plein écran et démarrer la lecture.

import { MuxPlayer } from '@capgo/capacitor-mux-player';
await MuxPlayer.play({ playbackId: 'playback-id-123' });

Fermer le player s'il est visible.

import { MuxPlayer } from '@capgo/capacitor-mux-player';
await MuxPlayer.dismiss();

Indique si le player est actuellement affiché.

import { MuxPlayer } from '@capgo/capacitor-mux-player';
const result = await MuxPlayer.isActive();
console.log(result);
export interface MuxPlayOptions {
/**
* The playback ID of the asset you want to stream.
*/
playbackId: string;
/**
* Provide a JSON web token generated for signed playback policies.
*/
playbackToken?: string;
/**
* Provide a JSON web token generated for DRM playback policies.
*/
drmToken?: string;
/**
* Override the default Mux playback domain (e.g. `stream.example.com`).
*/
customDomain?: string;
/**
* Auto-play when the player becomes visible. Defaults to true.
*/
autoPlay?: boolean;
/**
* Start playback from the provided time (in seconds).
*/
startTime?: number;
/**
* Provide a poster image URL to display before playback begins.
*/
poster?: string;
/**
* Provide a custom title to surface in native player chrome when available.
*/
title?: string;
/**
* Provide a subtitle or description to surface in native player chrome when available.
*/
subtitle?: string;
/**
* Set to true to keep the video muted when playback starts.
*/
muted?: boolean;
/**
* Mux Data environment key used for analytics. If omitted, the SDK default is used.
*/
environmentKey?: string;
/**
* Provide an explicit player name for analytics. Defaults to a generated name.
*/
playerName?: string;
/**
* Enable smart caching when the underlying SDK supports it.
*/
enableSmartCache?: boolean;
/**
* Enable verbose logging in native SDKs where available.
*/
debug?: boolean;
}
export interface MuxPlayerEvents {
/**
* Fired when the underlying player is ready to begin playback.
*/
ready: { playerName?: string };
/**
* Fired when playback starts or resumes.
*/
play: void;
/**
* Fired when playback pauses.
*/
pause: void;
/**
* Fired when playback ends.
*/
ended: void;
/**
* Fired when an unrecoverable error occurs.
*/
error: { message: string };
/**
* Fired when the fullscreen player is closed.
*/
playerDismissed: void;
/**
* Get the native Capacitor plugin version
*
* @returns {Promise<{ id: string }>} an Promise with version for this device
* @throws An error if the something went wrong
*/
getPluginVersion(): Promise<{ version: string }>;
}

Cette page est générée à partir de src/definitions.ts. Relancez la synchronisation lorsque l’API public change en amont.

Si vous utilisez Prise en main pour planifier les opérations du dashboard et de API, connectez-l’avec Utiliser @capgo/capacitor-mux-player pour la capacité native dans Utiliser @capgo/capacitor-mux-player, Aperçu de API pour les détails d'implémentation dans « Vue d'ensemble de API », Introduction pour les détails d'implémentation dans l'introduction, Clés API pour les détails d'implémentation dans « Clés API », et Appareils pour les détails d'implémentation dans Devices.