Per iniziare
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-mux-player`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/mux-player/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Puoi usare il nostro setup assistito dall'IA per installare il plugin. Aggiungi le skill Capgo al tuo strumento di IA usando il seguente comando:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsPoi usa il seguente prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-mux-player` plugin in my project.Se preferisci la configurazione manuale, installa il plugin eseguendo questi comandi e segui le istruzioni specifiche per piattaforma qui sotto:
bun add @capgo/capacitor-mux-playerbunx cap syncImporta
Sezione intitolata “Import”import { MuxPlayer } from '@capgo/capacitor-mux-player';Avvio rapido
Sezione intitolata “Quick start”import { MuxPlayer } from '@capgo/capacitor-mux-player';
const { active } = await MuxPlayer.isActive();if (active) return;await MuxPlayer.play({ playbackId: 'YOUR_PLAYBACK_ID',});Esempio: playback firmato
Sezione intitolata “Esempio: playback firmato”Passa il token di playback generato dal tuo backend per DRM o policy firmate, come documentato nel README del plugin.
Errori comuni
Sezione intitolata “Errori comuni”- Player singolo: controlla
isActive()prima di chiamareplay()ancora. - Ignora la pulizia: ascolta la chiusura se devi riprendere il video nella WebView inline in seguito.
- I token scadono: rigenera i JWT firmati lato server prima di sessioni lunghe.
Panoramica API
Sezione intitolata “Panoramica API”Avvia il Mux Player nativo a tutto schermo e avvia la riproduzione.
import { MuxPlayer } from '@capgo/capacitor-mux-player';
await MuxPlayer.play({ playbackId: 'playback-id-123' });dismiss
Sezione intitolata “dismiss”Chiudi il player se è visibile.
import { MuxPlayer } from '@capgo/capacitor-mux-player';
await MuxPlayer.dismiss();isActive
Sezione intitolata “isActive”Restituisce se il player è attualmente visualizzato.
import { MuxPlayer } from '@capgo/capacitor-mux-player';
const result = await MuxPlayer.isActive();console.log(result);Riferimento ai tipi
Sezione: “Type Reference”MuxPlayOptions
Sezione intitolata “MuxPlayOptions”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;}MuxPlayerEvents
Sezione intitolata “MuxPlayerEvents”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 }>;}Fonte di verità
Sezione intitolata “Fonte di verità”Questa pagina è generata dal src/definitions.ts. Riesegui la sync quando il API pubblico cambia upstream.
Continua da Getting Started
Sezione intitolata “Continua da Getting Started”Se stai usando Per iniziare per pianificare le operazioni della dashboard e di API, collegalo a Utilizzo di @capgo/capacitor-mux-player per la funzionalità nativa in Utilizzo di @capgo/capacitor-mux-player, Panoramica API per i dettagli di implementazione in Panoramica di API, Introduzione per i dettagli di implementazione in Introduzione, Chiavi API per i dettagli di implementazione in Chiavi API, e Dispositivi per i dettagli di implementazione in Dispositivi.