mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 16:31:13 +00:00
rewrote inner & shared 'video file view' with react (#3017)
* rewrote inner & shared 'video file view' with react * modification
This commit is contained in:
32
frontend/src/components/video-player.js
Normal file
32
frontend/src/components/video-player.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
|
||||
import videojs from 'video.js';
|
||||
import 'video.js/dist/video-js.css';
|
||||
|
||||
class VideoPlayer extends React.Component {
|
||||
componentDidMount() {
|
||||
// instantiate Video.js
|
||||
this.player = videojs(this.videoNode, this.props, function onPlayerReady() {
|
||||
});
|
||||
}
|
||||
|
||||
// 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 data-vjs-player>
|
||||
<video ref={ node => this.videoNode = node } className="video-js"></video>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default VideoPlayer;
|
Reference in New Issue
Block a user