mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-27 00:11:35 +01:00
Click video player to toggle playback
This commit is contained in:
parent
a39a92bd22
commit
0400734df7
1 changed files with 13 additions and 1 deletions
|
@ -46,11 +46,23 @@ const VideoPlayer = React.createClass({
|
||||||
this.setState({ muted: !this.state.muted });
|
this.setState({ muted: !this.state.muted });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleVideoClick (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
const node = ReactDOM.findDOMNode(this).querySelector('video');
|
||||||
|
|
||||||
|
if (node.paused) {
|
||||||
|
node.play();
|
||||||
|
} else {
|
||||||
|
node.pause();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<div style={{ cursor: 'default', marginTop: '8px', overflow: 'hidden', width: `${this.props.width}px`, height: `${this.props.height}px`, boxSizing: 'border-box', background: '#000', position: 'relative' }}>
|
<div style={{ cursor: 'default', marginTop: '8px', overflow: 'hidden', width: `${this.props.width}px`, height: `${this.props.height}px`, boxSizing: 'border-box', background: '#000', position: 'relative' }}>
|
||||||
<div style={muteStyle}><IconButton title='Toggle sound' icon={this.state.muted ? 'volume-up' : 'volume-off'} onClick={this.handleClick} /></div>
|
<div style={muteStyle}><IconButton title='Toggle sound' icon={this.state.muted ? 'volume-up' : 'volume-off'} onClick={this.handleClick} /></div>
|
||||||
<video src={this.props.media.get('url')} autoPlay='true' loop={true} muted={this.state.muted} style={videoStyle} />
|
<video src={this.props.media.get('url')} autoPlay='true' loop={true} muted={this.state.muted} style={videoStyle} onClick={this.handleVideoClick} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue