|
@@ -55,7 +55,7 @@ export default class Video extends Component {
|
|
constructor(props) {
|
|
constructor(props) {
|
|
super(props);
|
|
super(props);
|
|
this.ready = false;
|
|
this.ready = false;
|
|
- this.state = { id: generateUUID(8), playing: false, fulling: false, progress: 0 };
|
|
|
|
|
|
+ this.state = { id: generateUUID(8), playing: false, fulling: false, progress: 0, speed: 1 };
|
|
}
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
@@ -105,8 +105,8 @@ export default class Video extends Component {
|
|
|
|
|
|
onChangeProgress(value) {
|
|
onChangeProgress(value) {
|
|
if (!this.ready) return;
|
|
if (!this.ready) return;
|
|
- this.player.currentTime(this.player.duration() * value / 100);
|
|
|
|
- this.setState({ progress: this.player.currentTime() * 100 / this.player.duration() });
|
|
|
|
|
|
+ this.player.currentTime((this.player.duration() * value) / 100);
|
|
|
|
+ this.setState({ progress: (this.player.currentTime() * 100) / this.player.duration() });
|
|
}
|
|
}
|
|
|
|
|
|
onPlay() {
|
|
onPlay() {
|
|
@@ -137,6 +137,11 @@ export default class Video extends Component {
|
|
|
|
|
|
onSpeed(speed) {
|
|
onSpeed(speed) {
|
|
this.player.playbackRate(speed);
|
|
this.player.playbackRate(speed);
|
|
|
|
+ this.setState({ selectSpeed: false, speed });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ selectSpeed() {
|
|
|
|
+ this.setState({ selectSpeed: true });
|
|
}
|
|
}
|
|
|
|
|
|
onFullChange() {
|
|
onFullChange() {
|
|
@@ -155,7 +160,7 @@ export default class Video extends Component {
|
|
|
|
|
|
render() {
|
|
render() {
|
|
const { btnList = [], children, onAction, hideAction } = this.props;
|
|
const { btnList = [], children, onAction, hideAction } = this.props;
|
|
- const { playing, fulling, id } = this.state;
|
|
|
|
|
|
+ const { playing, fulling, id, selectSpeed, speed } = this.state;
|
|
return (
|
|
return (
|
|
<div id={id} className={`video-item ${!hideAction ? 'action' : ''} ${fulling ? 'full' : ''}`}>
|
|
<div id={id} className={`video-item ${!hideAction ? 'action' : ''} ${fulling ? 'full' : ''}`}>
|
|
<div className="video-wrapper">
|
|
<div className="video-wrapper">
|
|
@@ -163,7 +168,7 @@ export default class Video extends Component {
|
|
ref={node => {
|
|
ref={node => {
|
|
this.videoNode = node;
|
|
this.videoNode = node;
|
|
}}
|
|
}}
|
|
- // vjs-fluid
|
|
|
|
|
|
+ // vjs-fluid
|
|
/>
|
|
/>
|
|
{!playing && <Assets className="play" name="play" onClick={() => this.onPlay()} />}
|
|
{!playing && <Assets className="play" name="play" onClick={() => this.onPlay()} />}
|
|
{playing && <Assets className="stop" name="stop" onClick={() => this.onPause()} />}
|
|
{playing && <Assets className="stop" name="stop" onClick={() => this.onPause()} />}
|
|
@@ -171,47 +176,81 @@ export default class Video extends Component {
|
|
<div className="video-bottom">
|
|
<div className="video-bottom">
|
|
<div className="progress" />
|
|
<div className="progress" />
|
|
{/* {this.renderProgress()} */}
|
|
{/* {this.renderProgress()} */}
|
|
- {!hideAction && <div className="action-bar">
|
|
|
|
- <div className="d-i-b m-r-1">
|
|
|
|
- <Assets name={!playing ? 'play2' : 'stop2'} onClick={() => (playing ? this.onPause() : this.onPlay())} />
|
|
|
|
- {/* {playing && <Assets name="stop2" onClick={() => this.onPause()} />} */}
|
|
|
|
- </div>
|
|
|
|
- <div className="d-i-b m-r-1">
|
|
|
|
- <Assets name="next2" onClick={() => this.onNext()} />
|
|
|
|
- </div>
|
|
|
|
- {/* <div className="m-r-1">{this.ready ? (formatMinuteSecond(this.player.currentTime())) : ('00:00')}</div>
|
|
|
|
|
|
+ {!hideAction && (
|
|
|
|
+ <div className="action-bar">
|
|
|
|
+ <div className="d-i-b m-r-1">
|
|
|
|
+ <Assets
|
|
|
|
+ name={!playing ? 'play2' : 'stop2'}
|
|
|
|
+ onClick={() => (playing ? this.onPause() : this.onPlay())}
|
|
|
|
+ />
|
|
|
|
+ {/* {playing && <Assets name="stop2" onClick={() => this.onPause()} />} */}
|
|
|
|
+ </div>
|
|
|
|
+ <div className="d-i-b m-r-1">
|
|
|
|
+ <Assets name="next2" onClick={() => this.onNext()} />
|
|
|
|
+ </div>
|
|
|
|
+ {/* <div className="m-r-1">{this.ready ? (formatMinuteSecond(this.player.currentTime())) : ('00:00')}</div>
|
|
<div className="m-r-1">/{this.ready ? (formatMinuteSecond(this.player.duration())) : ('00:00')}</div> */}
|
|
<div className="m-r-1">/{this.ready ? (formatMinuteSecond(this.player.duration())) : ('00:00')}</div> */}
|
|
- <div className="flex-block" />
|
|
|
|
- {btnList.map(btn => {
|
|
|
|
- if (btn.full && !fulling) return '';
|
|
|
|
- if (!btn.show) return '';
|
|
|
|
- return (
|
|
|
|
- <div className="d-i-b m-r-1">
|
|
|
|
- {btn.render ? (
|
|
|
|
- <div className="fix-btn-action d-i-b" onClick={() => {
|
|
|
|
- if (btn.pause) this.onPause();
|
|
|
|
- if (onAction) onAction(btn.key);
|
|
|
|
- }}>
|
|
|
|
- {btn.render(btn.active)}
|
|
|
|
- </div>
|
|
|
|
- ) : (<div
|
|
|
|
- className={`btn-action ${btn.active ? 'active' : ''}`}
|
|
|
|
- onClick={() => onAction && onAction(btn.key)}
|
|
|
|
- >
|
|
|
|
- {btn.title}
|
|
|
|
- </div>)}
|
|
|
|
|
|
+ <div className="flex-block" />
|
|
|
|
+ {btnList.map(btn => {
|
|
|
|
+ if (btn.full && !fulling) return '';
|
|
|
|
+ if (!btn.show) return '';
|
|
|
|
+ return (
|
|
|
|
+ <div className="d-i-b m-r-1">
|
|
|
|
+ {btn.render ? (
|
|
|
|
+ <div
|
|
|
|
+ className="fix-btn-action d-i-b"
|
|
|
|
+ onClick={() => {
|
|
|
|
+ if (btn.pause) this.onPause();
|
|
|
|
+ if (onAction) onAction(btn.key);
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ {btn.render(btn.active)}
|
|
|
|
+ </div>
|
|
|
|
+ ) : (
|
|
|
|
+ <div
|
|
|
|
+ className={`btn-action ${btn.active ? 'active' : ''}`}
|
|
|
|
+ onClick={() => onAction && onAction(btn.key)}
|
|
|
|
+ >
|
|
|
|
+ {btn.title}
|
|
|
|
+ </div>
|
|
|
|
+ )}
|
|
|
|
+ </div>
|
|
|
|
+ );
|
|
|
|
+ })}
|
|
|
|
+ <div className="d-i-b m-r-1">
|
|
|
|
+ <div className={`btn-action ${selectSpeed ? 'active' : ''}`} onClick={() => this.selectSpeed()}>
|
|
|
|
+ 倍速
|
|
</div>
|
|
</div>
|
|
- );
|
|
|
|
- })}
|
|
|
|
- <div className="d-i-b m-r-1">
|
|
|
|
- <div className="btn-action">倍速</div>
|
|
|
|
|
|
+ </div>
|
|
|
|
+ <div className="d-i-b">
|
|
|
|
+ {!fulling && <Assets name="full2" onClick={() => this.onFull()} />}
|
|
|
|
+ {fulling && <Assets name="reduction2" onClick={() => this.onExitFull()} />}
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- <div className="d-i-b">
|
|
|
|
- {!fulling && <Assets name="full2" onClick={() => this.onFull()} />}
|
|
|
|
- {fulling && <Assets name="reduction2" onClick={() => this.onExitFull()} />}
|
|
|
|
- </div>
|
|
|
|
- </div>}
|
|
|
|
|
|
+ )}
|
|
</div>
|
|
</div>
|
|
|
|
+ {selectSpeed && (
|
|
|
|
+ <div className="select-speed">
|
|
|
|
+ <div className={`item ${speed === 0.5 ? 'active' : ''}`} onClick={() => this.onSpeed(0.5)}>
|
|
|
|
+ 0.5
|
|
|
|
+ </div>
|
|
|
|
+ <div className={`item ${speed === 0.75 ? 'active' : ''}`} onClick={() => this.onSpeed(0.75)}>
|
|
|
|
+ 0.75
|
|
|
|
+ </div>
|
|
|
|
+ <div className={`item ${speed === 1 ? 'active' : ''}`} onClick={() => this.onSpeed(1)}>
|
|
|
|
+ 正常
|
|
|
|
+ </div>
|
|
|
|
+ <div className={`item ${speed === 1.25 ? 'active' : ''}`} onClick={() => this.onSpeed(1.25)}>
|
|
|
|
+ 1.25
|
|
|
|
+ </div>
|
|
|
|
+ <div className={`item ${speed === 1.5 ? 'active' : ''}`} onClick={() => this.onSpeed(1.5)}>
|
|
|
|
+ 1.5
|
|
|
|
+ </div>
|
|
|
|
+ <div className={`item ${speed === 2.0 ? 'active' : ''}`} onClick={() => this.onSpeed(2)}>
|
|
|
|
+ 2.0
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ )}
|
|
{children}
|
|
{children}
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
@@ -220,6 +259,10 @@ export default class Video extends Component {
|
|
renderProgress() {
|
|
renderProgress() {
|
|
const { hideProgress } = this.props;
|
|
const { hideProgress } = this.props;
|
|
const { progress } = this.state;
|
|
const { progress } = this.state;
|
|
- return !hideProgress && <Slider value={progress || 0} tooltipVisible={false} onChange={(value) => this.onChangeProgress(value)} />;
|
|
|
|
|
|
+ return (
|
|
|
|
+ !hideProgress && (
|
|
|
|
+ <Slider value={progress || 0} tooltipVisible={false} onChange={value => this.onChangeProgress(value)} />
|
|
|
|
+ )
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|