Preload stream

This commit is contained in:
Nick Mowen 2022-12-16 07:16:53 -07:00
parent c2cda49a2e
commit 17fd7be4bf

View File

@ -7,6 +7,7 @@ import RecordingPlaylist from '../components/RecordingPlaylist';
import VideoPlayer from '../components/VideoPlayer';
import { useApiHost } from '../api';
import useSWR from 'swr';
import axios from 'axios';
export default function Recording({ camera, date, hour = '00', minute = '00', second = '00' }) {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
@ -98,8 +99,13 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se
useEffect(() => {
if (this.player) {
this.player.playlist.currentItem(playlistIndex);
// prime next item in playlist
if (playlistIndex < playlist.length - 1) {
axios.get(playlist?.get(playlistIndex + 1))
}
}
}, [playlistIndex]);
}, [playlist, playlistIndex]);
useEffect(() => {
if (this.player) {
@ -135,6 +141,9 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se
<div className="text-xs">Dates and times are based on the browser's timezone {timezone}</div>
<VideoPlayer
options={{
preload: 'auto',
}}
onReady={(player) => {
player.on('ratechange', () => player.defaultPlaybackRate(player.playbackRate()));
if (player.playlist) {