mirror of
https://github.com/owncast/owncast.git
synced 2024-11-26 23:24:29 +03:00
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import VideoJS from './player';
|
|
|
|
export default function OwncastPlayer(props) {
|
|
const playerRef = React.useRef(null);
|
|
const { source } = props;
|
|
|
|
const videoJsOptions = {
|
|
autoplay: false,
|
|
controls: true,
|
|
responsive: true,
|
|
fluid: false,
|
|
playsInline: true,
|
|
liveui: true,
|
|
preload: 'auto',
|
|
controlBar: {
|
|
progressControl: {
|
|
seekBar: false,
|
|
},
|
|
},
|
|
html5: {
|
|
vhs: {
|
|
// used to select the lowest bitrate playlist initially. This helps to decrease playback start time. This setting is false by default.
|
|
enableLowInitialPlaylist: true,
|
|
experimentalBufferBasedABR: true,
|
|
useNetworkInformationApi: true,
|
|
maxPlaylistRetries: 30,
|
|
},
|
|
},
|
|
liveTracker: {
|
|
trackingThreshold: 0,
|
|
liveTolerance: 15,
|
|
},
|
|
sources: [
|
|
{
|
|
src: `${source}/hls/stream.m3u8`,
|
|
type: 'application/x-mpegURL',
|
|
},
|
|
],
|
|
};
|
|
|
|
const handlePlayerReady = player => {
|
|
playerRef.current = player;
|
|
|
|
// You can handle player events here, for example:
|
|
player.on('waiting', () => {
|
|
player.log('player is waiting');
|
|
});
|
|
|
|
player.on('dispose', () => {
|
|
player.log('player will dispose');
|
|
});
|
|
};
|
|
|
|
return <VideoJS options={videoJsOptions} onReady={handlePlayerReady} />;
|
|
}
|