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);
|
||||
}
|
||||
|
||||
function onPause() {
|
||||
setIsPlaying(false);
|
||||
}
|
||||
|
||||
const onPlayerReady = useCallback(
|
||||
(player: Player) => {
|
||||
if (!embedded) {
|
||||
|
@ -144,7 +140,10 @@ function VideoViewer(props: Props) {
|
|||
player.on('tracking:firstplay', doTrackingFirstPlay);
|
||||
player.on('ended', onEnded);
|
||||
player.on('play', onPlay);
|
||||
player.on('pause', onPause);
|
||||
player.on('pause', () => {
|
||||
setIsPlaying(false);
|
||||
savePosition(uri, player.currentTime());
|
||||
});
|
||||
player.on('volumechange', () => {
|
||||
if (player && player.volume() !== volume) {
|
||||
changeVolume(player.volume());
|
||||
|
@ -157,7 +156,7 @@ function VideoViewer(props: Props) {
|
|||
if (position) {
|
||||
player.currentTime(position);
|
||||
}
|
||||
player.on('timeupdate', () => savePosition(uri, player.currentTime()));
|
||||
player.on('dispose', () => savePosition(uri, player.currentTime()));
|
||||
},
|
||||
[uri]
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue