mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
fbd023c032
* added videojs integration example * added videojs example * lint fix * Revert "lint fix" This reverts commit 39010fa0b58a66d06b91987a5bef46c044181470. * removed unexpected lint fix
36 lines
866 B
JavaScript
36 lines
866 B
JavaScript
import React, { Component } from 'react'
|
|
import videojs from 'video.js'
|
|
import 'videojs-youtube'
|
|
import 'video.js/dist/video-js.css'
|
|
|
|
class Player extends Component {
|
|
componentDidMount () {
|
|
// instantiate Video.js
|
|
this.player = videojs(this.videoNode, this.props, function onPlayerReady () {
|
|
console.log('onPlayerReady', this)
|
|
})
|
|
}
|
|
|
|
// destroy player on unmount
|
|
componentWillUnmount () {
|
|
if (this.player) {
|
|
this.player.dispose()
|
|
}
|
|
}
|
|
|
|
// wrap the player in a div with a `data-vjs-player` attribute
|
|
// so videojs won't create additional wrapper in the DOM
|
|
// see https://github.com/videojs/video.js/pull/3856
|
|
render () {
|
|
return (
|
|
<div>
|
|
<div data-vjs-player>
|
|
<video ref={node => (this.videoNode = node)} className='video-js' />
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default Player
|