From 9c79b79b2f53fc99da57ed14bb4daea8dbae69a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Baz=C3=ADlio=20Ribeiro?= Date: Wed, 26 Apr 2023 09:05:57 +0100 Subject: [PATCH 1/2] Add keep playing when using seekTo This an option override to the default pause for Youtube player --- src/Player.js | 6 +++--- src/ReactPlayer.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Player.js b/src/Player.js index c8242df7..c37ff8bf 100644 --- a/src/Player.js +++ b/src/Player.js @@ -144,7 +144,7 @@ export default class Player extends Component { this.progressTimeout = setTimeout(this.progress, this.props.progressFrequency || this.props.progressInterval) } - seekTo (amount, type) { + seekTo (amount, type, keepPlaying = false) { // When seeking before player is ready, store value and seek later if (!this.isReady) { if (amount !== 0) { @@ -161,10 +161,10 @@ export default class Player extends Component { console.warn('ReactPlayer: could not seek using fraction – duration not yet available') return } - this.player.seekTo(duration * amount) + this.player.seekTo(duration * amount, keepPlaying) return } - this.player.seekTo(amount) + this.player.seekTo(amount, keepPlaying) } handleReady = () => { diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index b165ea43..4770e604 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -98,9 +98,9 @@ export const createReactPlayer = (players, fallback) => { return this.player.getInternalPlayer(key) } - seekTo = (fraction, type) => { + seekTo = (fraction, type, keepPlaying) => { if (!this.player) return null - this.player.seekTo(fraction, type) + this.player.seekTo(fraction, type, keepPlaying) } handleReady = () => { From fbc44692284890978062eff53bef7aa7c031f36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Baz=C3=ADlio=20Ribeiro?= Date: Wed, 26 Apr 2023 09:06:28 +0100 Subject: [PATCH 2/2] Add keepPlaying to youtube player --- src/players/YouTube.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/players/YouTube.js b/src/players/YouTube.js index 869919ce..d5f95dd5 100644 --- a/src/players/YouTube.js +++ b/src/players/YouTube.js @@ -143,9 +143,9 @@ export default class YouTube extends Component { this.callPlayer('stopVideo') } - seekTo (amount) { + seekTo (amount, keepPlaying) { this.callPlayer('seekTo', amount) - if (!this.props.playing) { + if (!keepPlaying && !this.props.playing) { this.pause() } }