Skip to content

Commit

Permalink
Adjust listener for kaltura (#1226)
Browse files Browse the repository at this point in the history
* Adjust listener for kaltura

Fixes #1202 and related to #1082.

* Fix lint

As mentioned in #1225 `findDOMNode` is deprecated.

* Add autoplay to iframe props

* Move code to load method and call it instead

* Update src/players/Kaltura.js

Co-authored-by: Pete Cook <pete@cookpete.com>

* Remove `this.load()` call in `componentDidMount`

Co-authored-by: Pete Cook <pete@cookpete.com>
  • Loading branch information
Yasamato and cookpete authored Feb 20, 2022
1 parent 96bf771 commit e2afc10
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/players/Kaltura.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down Expand Up @@ -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'
/>
)
Expand Down

0 comments on commit e2afc10

Please sign in to comment.