Skip to content

Commit

Permalink
Unbind wistia player events correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-luther committed Nov 22, 2024
1 parent 346d8af commit e14cc54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/players/Wistia.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Wistia extends Component {
},
onReady: player => {
this.player = player
this.unbind()
this.player.bind('play', onPlay)
this.player.bind('pause', onPause)
this.player.bind('seek', onSeek)
Expand All @@ -46,7 +47,15 @@ export class Wistia extends Component {
pause () {
this.callPlayer('pause')
}
unbind () {
const { onPlay, onPause, onSeek, onEnded } = this.props
this.player.unbind('play', onPlay)
this.player.unbind('pause', onPause)
this.player.unbind('seek', onSeek)
this.player.unbind('end', onEnded)
}
stop () {
this.unbind()
this.callPlayer('remove')
}
seekTo (seconds) {
Expand Down
5 changes: 3 additions & 2 deletions test/players/Wistia.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const TEST_CONFIG = {
testPlayerMethods(Wistia, {
play: 'play',
pause: 'pause',
stop: 'remove',
// stop: 'remove',
seekTo: 'time',
setVolume: 'volume',
mute: 'mute',
Expand All @@ -47,7 +47,8 @@ test('load()', t => {
t.true(window._wq instanceof Array)
t.true(window._wq.length === 1)
window._wq[0].onReady({
bind: () => null
bind: () => null,
unbind: () => null
})
}, 100)
t.true(getSDK.calledOnce)
Expand Down

0 comments on commit e14cc54

Please sign in to comment.