@antmedia/web_player

中文文档
2.13.2发布于 2026/09/07ISCTypeScriptES Module构建来源已验证近 30 天下载 2964

Ant Media Server Player that can play WebRTC, HLS, DASH

原始使用文档
文档目录9 节
  1. Features
  2. Installation
  3. Usage
  4. Basic Usage
  5. Advanced Usage
  6. Configuration Parameters
  7. Support
  8. Issues
  9. Contributing

Web Player for Ant Media Server

Web Player is a powerful, versatile player for Ant Media Server, designed to embed and play streams directly in web applications. It supports various stream types including WebRTC, HLS, DASH, and VR 360, ensuring broad compatibility and high performance. The player can be easily configured via URL parameters or directly in your code, offering both flexibility and ease of use.

Features

  • Supports WebRTC, HLS, DASH, and VR 360 streams.
  • Configurable through URL parameters or directly in the code.
  • Supports token-based security for stream access.
  • Autoplay and mute options for a seamless user experience.
  • Customizable play order and types for different stream technologies and formats.
  • Adjustable target latency for DASH players.
  • 360-degree video playback capability.

Installation

Install the Web Player package using npm:

npm i @antmedia/web_player

Usage

Basic Usage

To use the Web Player, import it and initialize it with the parameters received from the URL. Refer to the Configuration Parameters section below for more details.

  1. In your web application, create a div with the id video_container. This will serve as the container for the player.
<div id="video_container" ></div>
  1. Initialize the player as follows:
import { WebPlayer } from "@antmedia/web_player";

var embeddedPlayer = new WebPlayer(window, document.getElementById("video_container"), null);

embeddedPlayer.initialize().then(() => {
  embeddedPlayer.play();
});

The sample for this usage is available in play.html in StreamApp

Advanced Usage

Alternatively, you can pass the parameters as an object to the WebPlayer constructor.

  1. In your web application, create a div with the id video_container. This will serve as the container for the player.
<div id="video_container" ></div>
  1. Initialize the player as follows
var player = new WebPlayer({
  streamId: "myStreamId",
  httpBaseURL: "http://example.antmedia.io:5080/WebRTCAppEE/", //Remember to add trailing slash(/)
}, document.getElementById("video_container"), null);

player.initialize().then(() => {
  player.play();
}).catch((error) => {
  console.error("Error while initializing embedded player: " + error);
});

The sample for this usage is available in app.page.component.ts in Ant-Media-Management-Console

Configuration Parameters

The player accepts several configuration parameters, either through the URL or directly in the code:

  1. id (String): The stream ID to play. This parameter is mandatory.
  2. token (String): The token for stream access. It's mandatory if token security is enabled on the server side.
  3. autoplay (Boolean): Autoplay the stream if available. Optional. Default value is true.
  4. mute (Boolean): Start playing in mute mode if the stream is available. Optional. Default value is true.
  5. playOrder (String): The order of technologies used for playing. Optional. Default value is "webrtc,hls". Possible values include "hls,webrtc", "webrtc", "hls", "vod", "dash".
  6. playType (String): The order of play types used for playing. Optional. Default value is "mp4,webm". Possible values include "webm,mp4", "mp4", "webm", "mov".
  7. targetLatency (Number): The target latency for the DASH player. Optional. Default value is 3.
  8. is360 (Boolean): Enable playback in 360 mode. Optional. Default value is false.

Support

For support and further inquiries, please visit Ant Media Server's community. If you are an enterprise user, you can receive support by sending an email to [email protected].

Issues

For reporting issues, please create them on the Ant-Media-Server issues page.

Contributing

Contributions are warmly welcomed. If you would like to help improve the Web Player, please submit your pull requests to the repository or report any issues you encounter.

Enjoy streaming with the Ant Media Server's Web Player!

版本与发布记录

@antmedia/web_player 共发布 67 个版本,首次发布于 2024/01/22;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.13.2latest2026/09/072 个月前
2.13.12026/08/272 个月前
3.0.0-SNAPSHOT-2026-May-18-02-44SNAPSHOT2026/05/185 个月前
3.0.0-SNAPSHOT-2026-May-18-08-572026/05/185 个月前
3.0.0-SNAPSHOT-2026-May-18-08-472026/05/185 个月前
3.0.0-SNAPSHOT-2026-Mar-17-01-002026/03/177 个月前

其他发布通道:ALPHA → 2.9.1-ALPHA-15-05-2024,SNAPSHOT → 3.0.0-SNAPSHOT-2026-May-18-02-44。

关于 @antmedia/web_player 的常见问题

@antmedia/web_player 是什么?

Ant Media Server Player that can play WebRTC, HLS, DASH

如何安装 @antmedia/web_player?

在项目目录运行 npm install @antmedia/web_player,或使用 pnpm add / yarn add / bun add。

@antmedia/web_player 支持 TypeScript 吗?

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

@antmedia/web_player 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@antmedia/web_player 可以商用吗?

@antmedia/web_player 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@antmedia/web_player 的下载量有多少?

根据 npm 官方下载统计,@antmedia/web_player 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,964 次,日均约 99 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@antmedia/web_player 还在维护吗?

最新版本 2.13.2 发布于 2026/09/07(2 个月前);至今共发布 67 个版本,其中过去 12 个月发布了 6 个;首次发布于 2024/01/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。