about summary refs log tree commit diff
path: root/app/assets/javascripts/components
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-07 19:05:32 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-07 19:05:32 +0100
commit0400734df7a38f4b100d601eb8cffd7cd9689c76 (patch)
treed1daff819de3499b775851166ff9b4f5092590f5 /app/assets/javascripts/components
parenta39a92bd22b89f09b9f208b767e2a674aaa05777 (diff)
Click video player to toggle playback
Diffstat (limited to 'app/assets/javascripts/components')
-rw-r--r--app/assets/javascripts/components/components/video_player.jsx14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/components/video_player.jsx b/app/assets/javascripts/components/components/video_player.jsx
index fcf966d83..209db33a7 100644
--- a/app/assets/javascripts/components/components/video_player.jsx
+++ b/app/assets/javascripts/components/components/video_player.jsx
@@ -46,11 +46,23 @@ const VideoPlayer = React.createClass({
     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 () {
     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={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>
     );
   }