# @glomex/integration-react 中文文档

规范地址：https://npmcn.com/package/%40glomex/integration-react/

版本：1\.1597\.2
npm 元数据更新时间：2026-10-30T17:26:02.541Z
中文译文更新时间：2026-11-16T16:32:17.896Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40glomex/integration-react
原文对照：https://npmcn.com/package/%40glomex/integration-react/?lang=original
项目主页：https://glomex.com/

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：162 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \>=16\.8\.0，preact \>=10，react-dom \>=16\.8\.0
- 首次发布：2025-04-07T07:31:47.621Z
- 最新版本发布：2026-10-30T17:26:02.363Z
- 近 30 天下载量：2872（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：498（近 12 个月 250 个）

## 中文简介

用于整合 glomex 播放器的反射组件

## 安装

```sh
npm install @glomex/integration-react
```

也可以使用：`pnpm add @glomex/integration-react`、`yarn add @glomex/integration-react`、`bun add @glomex/integration-react`

## README

# @ glomex/ 整合- 反应

## 导言

`@glomex/integration-react` 曝光一个反应组件和类型,以方便地整合 glomex 播放器. 要使用此组件, 您需要有一个 glomex 账户 。 你可以通过遵守指令来获得一个 [开始](https://docs.glomex.com/publisher/getting-started) 节.

## 关于闪光剂

[光泽](https://glomex.com/) 经营着德国最大的高价视频内容市场。 我们的平台连接出版商,内容创作商,广告商,使得高质量的视频内容能够无缝地在网络上畅通地发售.

我们的生态系统旨在为所有参与者创造价值:

-   **出版商** 获得优质视频内容和货币化机会
-   **内容拥有者** 其视频资产获得广泛的分配和收入
-   **广告商** 覆盖优质网站网络的目标受众

## 使用量

### 正在装入并整合播放器( TypeScript)

```tsx
// example: player.tsx
import { useEffect, useRef, type ComponentProps, type ComponentRef } from 'react';
import { Integration, IntegrationEvent } from '@glomex/integration-react';

const Player = (props: ComponentProps<typeof Integration>) => {
  const integrationRef = useRef<ComponentRef<typeof Integration>>(null);

  const handlePlay = () => {
    integrationRef.current?.ready.then(() => integrationRef.current?.play());
  };

  const handleContentStart = () => {
    console.log('content start', integrationRef.current?.content);
  };

  useEffect(() => {
    integrationRef.current?.ready.then(() => {
      // interact with the API after initial ready
      if (!integrationRef.current) return;
      // e.g. start at 20 seconds
      integrationRef.current.currentTime = 20;
      // integrationRef.current.volume = 0.1
      // integrationRef.current.muted = true
      // integrationRef.current.play();
    });
    // addEventListener is available immediately (without ready)
    integrationRef.current?.addEventListener(
      IntegrationEvent.CONTENT_START,
      handleContentStart
    );
    return () => {
      integrationRef.current?.removeEventListener(
        IntegrationEvent.CONTENT_START,
        handleContentStart
      );
    };
  }, [integrationRef]);

  return (
    <div>
      <Integration
        ref={integrationRef}
        {...props}
      />
      <button type="button" onClick={handlePlay}>
        Play
      </button>
    </div>
  );
};

export default Player;
```

**使用量** 在组件中:

```tsx
// example: app.tsx
import Player from "./player"

export default async function MyApp(props) {
  const params = await props.params

  return (
    <div>
      <Player
        integrationId="YOUR_INTEGRATION_ID"
        playlistId="YOUR_PLAYLIST_ID"
      />
    </div>
  );
}
```

## 常见问题

### @glomex/integration-react 是什么？

用于整合 glomex 播放器的反射组件

### 如何安装 @glomex/integration-react？

在项目目录运行 npm install @glomex/integration-react，或使用 pnpm add / yarn add / bun add。

### @glomex/integration-react 支持 TypeScript 吗？

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

### @glomex/integration-react 支持 ESM 还是 CommonJS？

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

### @glomex/integration-react 可以商用吗？

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

### @glomex/integration-react 的下载量有多少？

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

### @glomex/integration-react 还在维护吗？

最新版本 1\.1597\.2 发布于 2026/10/31（16 天前）；至今共发布 498 个版本，其中过去 12 个月发布了 250 个；首次发布于 2025/04/07。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

