You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
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} />; |
|
}
|
|
|