@capgo/capacitor-mux-player

中文文档
8.1.2发布于 2026/10/15MPL-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 4万

Native Mux Player SDK to play video on IOS and Android

原始使用文档
文档目录15 节
  1. ➡️ Get started for free
  2. Key features
  3. Documentation
  4. Compatibility
  5. Install
  6. iOS setup
  7. Android setup
  8. Web setup
  9. API
  10. play(...)
  11. dismiss()
  12. isActive()
  13. removeAllListeners()
  14. addListener(E, ...)
  15. Interfaces

@capgo/capacitor-mux-player

Play Mux videos in your Capacitor app with the native Mux Player SDKs on iOS and Android, including Mux Data playback analytics.

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-mux-player in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-mux-player to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-mux-player for Capacitor apps

Key features

  • Fullscreen playback: play() opens the native Mux Player with a playback ID.
  • Dismiss: dismiss() closes the player.
  • State: isActive() reports whether the player is showing.
  • Native SDKs: Mux Player Swift on iOS and the Mux Player Android SDK, with Mux Data stats.
  • Platforms: iOS, Android and Web. Web provides a basic fallback player.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/mux-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-mux-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-mux-player
npx cap sync

iOS setup

  • Requires iOS 15 or newer.
  • Add the Swift package https://github.com/muxinc/mux-player-swift to your Xcode workspace so that the MuxPlayerSwift module is available at build time.
  • If you manage native dependencies through CocoaPods, prefer integrating this plugin via Swift Package Manager or add the Mux package manually to your app target.

Android setup

  • Gradle pulls the player from the Mux artifactory (https://muxinc.jfrog.io/artifactory/default-maven-release-local). Ensure your corporate proxy allows downloads from that host.
  • npx cap sync android adds the Mux Maven repository to android/build.gradle automatically. If Capacitor lifecycle hooks are disabled in your project, add that repository manually to the root Gradle configuration (android/build.gradle).
  • The plugin uses Kotlin 2.2.20 and resolves Media3 transitively through the Mux artifact.
  • Android apps targeting SDK 33 or newer will also see android.permission.POST_NOTIFICATIONS merged from this library. The plugin does not request notifications at runtime; the manifest entry prevents Android lint failures caused by Mux's Glide NotificationTarget dependency. If your app does not need that permission, remove it from your app manifest with:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission
        android:name="android.permission.POST_NOTIFICATIONS"
        tools:node="remove" />
</manifest>

Web setup

  • The plugin bundles @mux/mux-player and renders the video in a fullscreen overlay. The player automatically injects a close affordance for desktop and mobile browsers.

API

play(...)

play(options: MuxPlayOptions) => Promise<void>

Launch the native Mux Player in fullscreen and begin playback.

ParamType
optionsMuxPlayOptions

dismiss()

dismiss() => Promise<void>

Dismiss the player if it is visible.


isActive()

isActive() => Promise<{ active: boolean; }>

Returns whether the player is currently being displayed.

Returns: Promise<{ active: boolean; }>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all event listeners registered on the plugin instance.


addListener(E, ...)

addListener<E extends keyof MuxPlayerEvents>(eventName: E, listenerFunc: (event: MuxPlayerEvents[E]) => void) => Promise<PluginListenerHandle>

Listen to player lifecycle or playback events emitted by the plugin.

ParamType
eventNameE
listenerFunc(event: MuxPlayerEvents[E]) => void

Returns: Promise<PluginListenerHandle>


Interfaces

MuxPlayOptions

PropTypeDescription
playbackIdstringThe playback ID of the asset you want to stream.
playbackTokenstringProvide a JSON web token generated for signed playback policies.
drmTokenstringProvide a JSON web token generated for DRM playback policies.
customDomainstringOverride the default Mux playback domain (e.g. stream.example.com).
autoPlaybooleanAuto-play when the player becomes visible. Defaults to true.
startTimenumberStart playback from the provided time (in seconds).
posterstringProvide a poster image URL to display before playback begins.
titlestringProvide a custom title to surface in native player chrome when available.
subtitlestringProvide a subtitle or description to surface in native player chrome when available.
mutedbooleanSet to true to keep the video muted when playback starts.
environmentKeystringMux Data environment key used for analytics. If omitted, the SDK default is used.
playerNamestringProvide an explicit player name for analytics. Defaults to a generated name.
enableSmartCachebooleanEnable smart caching when the underlying SDK supports it.
debugbooleanEnable verbose logging in native SDKs where available.

PluginListenerHandle

PropType
remove() => Promise<void>

MuxPlayerEvents

PropTypeDescription
ready{ playerName?: string; }Fired when the underlying player is ready to begin playback.
playvoidFired when playback starts or resumes.
pausevoidFired when playback pauses.
endedvoidFired when playback ends.
error{ message: string; }Fired when an unrecoverable error occurs.
playerDismissedvoidFired when the fullscreen player is closed.
MethodSignatureDescription
getPluginVersion() => Promise<{ version: string; }>Get the native Capacitor plugin version

版本与发布记录

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

版本发布日期距今
8.1.2latest2026/10/1525 天前
8.1.12026/10/1327 天前
8.1.02026/10/091 个月前
8.0.202026/10/081 个月前
8.0.192026/09/161 个月前
8.0.182026/08/202 个月前

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

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

Native Mux Player SDK to play video on IOS and Android

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

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

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

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

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

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

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

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

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

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

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

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