@ glomex/ 整合- 反应
导言
@glomex/integration-react 曝光一个反应组件和类型,以方便地整合 glomex 播放器. 要使用此组件, 您需要有一个 glomex 账户 。 你可以通过遵守指令来获得一个 开始 节.
关于闪光剂
光泽 经营着德国最大的高价视频内容市场。 我们的平台连接出版商,内容创作商,广告商,使得高质量的视频内容能够无缝地在网络上畅通地发售.
我们的生态系统旨在为所有参与者创造价值:
- 出版商 获得优质视频内容和货币化机会
- 内容拥有者 其视频资产获得广泛的分配和收入
- 广告商 覆盖优质网站网络的目标受众
使用量
正在装入并整合播放器( TypeScript)
// 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;
使用量 在组件中:
// 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>
);
}