diff --git a/src/players/Kaltura.js b/src/players/Kaltura.js index 419b3992..7bc9be80 100644 --- a/src/players/Kaltura.js +++ b/src/players/Kaltura.js @@ -23,32 +23,32 @@ export default class Kaltura extends Component { if (!this.iframe) return this.player = new playerjs.Player(this.iframe) this.player.on('ready', () => { - this.player.isReady = true - this.player.on('play', this.props.onPlay) - this.player.on('pause', this.props.onPause) - this.player.on('seeked', this.props.onSeek) - this.player.on('ended', this.props.onEnded) - this.player.on('error', this.props.onError) - this.player.on('timeupdate', ({ duration, seconds }) => { - this.duration = duration - this.currentTime = seconds - }) - this.player.on('buffered', ({ percent }) => { - if (this.duration) { - this.secondsLoaded = this.duration * percent - } - }) - this.player.setLoop(this.props.loop) - if (this.props.muted) { - this.player.mute() - } + // An arbitrary timeout is required otherwise + // the event listeners won’t work setTimeout(() => { + this.player.isReady = true + this.player.setLoop(this.props.loop) + if (this.props.muted) { + this.player.mute() + } + this.addListeners(this.player, this.props) this.props.onReady() - }) + }, 500) }) }, this.props.onError) } + addListeners (player, props) { + player.on('play', props.onPlay) + player.on('pause', props.onPause) + player.on('ended', props.onEnded) + player.on('error', props.onError) + player.on('timeupdate', ({ duration, seconds }) => { + this.duration = duration + this.currentTime = seconds + }) + } + play () { this.callPlayer('play') } @@ -110,7 +110,7 @@ export default class Kaltura extends Component { scrolling='no' style={style} allowFullScreen - allow='encrypted-media' + allow='encrypted-media;autoplay' referrerPolicy='no-referrer-when-downgrade' /> )