Only save media position on pause or dispose, not every timeupdate, for performance reasons.
This commit is contained in:
parent
3b7bba5ba3
commit
7ea9c1c199
1 changed files with 5 additions and 6 deletions
|
@ -106,10 +106,6 @@ function VideoViewer(props: Props) {
|
||||||
setIsEndededEmbed(false);
|
setIsEndededEmbed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPause() {
|
|
||||||
setIsPlaying(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
const onPlayerReady = useCallback(
|
const onPlayerReady = useCallback(
|
||||||
(player: Player) => {
|
(player: Player) => {
|
||||||
if (!embedded) {
|
if (!embedded) {
|
||||||
|
@ -144,7 +140,10 @@ function VideoViewer(props: Props) {
|
||||||
player.on('tracking:firstplay', doTrackingFirstPlay);
|
player.on('tracking:firstplay', doTrackingFirstPlay);
|
||||||
player.on('ended', onEnded);
|
player.on('ended', onEnded);
|
||||||
player.on('play', onPlay);
|
player.on('play', onPlay);
|
||||||
player.on('pause', onPause);
|
player.on('pause', () => {
|
||||||
|
setIsPlaying(false);
|
||||||
|
savePosition(uri, player.currentTime());
|
||||||
|
});
|
||||||
player.on('volumechange', () => {
|
player.on('volumechange', () => {
|
||||||
if (player && player.volume() !== volume) {
|
if (player && player.volume() !== volume) {
|
||||||
changeVolume(player.volume());
|
changeVolume(player.volume());
|
||||||
|
@ -157,7 +156,7 @@ function VideoViewer(props: Props) {
|
||||||
if (position) {
|
if (position) {
|
||||||
player.currentTime(position);
|
player.currentTime(position);
|
||||||
}
|
}
|
||||||
player.on('timeupdate', () => savePosition(uri, player.currentTime()));
|
player.on('dispose', () => savePosition(uri, player.currentTime()));
|
||||||
},
|
},
|
||||||
[uri]
|
[uri]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue