mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-13 15:05:30 +00:00
33 lines
796 B
JavaScript
33 lines
796 B
JavaScript
import React from 'react';
|
|
|
|
import videojs from 'video.js';
|
|
import 'video.js/dist/video-js.css';
|
|
|
|
class AudioPlayer 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>
|
|
<audio ref={ node => this.videoNode = node } className="video-js vjs-has-started"></audio>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default AudioPlayer;
|