2022-04-27 05:29:13 +03:00
|
|
|
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,
|
2022-05-03 08:13:36 +03:00
|
|
|
fluid: false,
|
|
|
|
playsInline: true,
|
2022-04-27 05:29:13 +03:00
|
|
|
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} />;
|
|
|
|
}
|