Skip to content

Commit

Permalink
Adding keepPlaying to other player types (#1639)
Browse files Browse the repository at this point in the history
* Add keep playing when using seekTo

This an option override to the default pause for Youtube player

* Add keepPlaying to youtube player
* Add keepPlaying to other players
* Move default value to specific player
  • Loading branch information
David Ribeiro authored Aug 28, 2023
1 parent 7034036 commit 2efb40a
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default class Player extends Component {
this.progressTimeout = setTimeout(this.progress, this.props.progressFrequency || this.props.progressInterval)
}

seekTo (amount, type, keepPlaying = false) {
seekTo (amount, type, keepPlaying) {
// When seeking before player is ready, store value and seek later
if (!this.isReady) {
if (amount !== 0) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/DailyMotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ export default class DailyMotion extends Component {
// Nothing to do
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('seek', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ export default class Facebook extends Component {
// Nothing to do
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('seek', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,11 @@ export default class FilePlayer extends Component {
}
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.player.currentTime = seconds
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Kaltura.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ export default class Kaltura extends Component {
// Nothing to do
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('setCurrentTime', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Mixcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ export default class Mixcloud extends Component {
// Nothing to do
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('seek', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/SoundCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ export default class SoundCloud extends Component {
// Nothing to do
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('seekTo', seconds * 1000)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Streamable.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ export default class Streamable extends Component {
// Nothing to do
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('setCurrentTime', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Twitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ export default class Twitch extends Component {
this.callPlayer('pause')
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('seek', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Vidyard.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ export default class Vidyard extends Component {
window.VidyardV4.api.destroyPlayer(this.player)
}

seekTo (amount) {
seekTo (amount, keepPlaying = true) {
this.callPlayer('seek', amount)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ export default class Vimeo extends Component {
this.callPlayer('unload')
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('setCurrentTime', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
5 changes: 4 additions & 1 deletion src/players/Wistia.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ export default class Wistia extends Component {
this.callPlayer('remove')
}

seekTo (seconds) {
seekTo (seconds, keepPlaying = true) {
this.callPlayer('time', seconds)
if (!keepPlaying) {
this.pause()
}
}

setVolume (fraction) {
Expand Down
2 changes: 1 addition & 1 deletion src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default class YouTube extends Component {
this.callPlayer('stopVideo')
}

seekTo (amount, keepPlaying) {
seekTo (amount, keepPlaying = false) {
this.callPlayer('seekTo', amount)
if (!keepPlaying && !this.props.playing) {
this.pause()
Expand Down

0 comments on commit 2efb40a

Please sign in to comment.