2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
|
|
|
import Link from 'component/link';
|
2017-06-07 07:36:12 +02:00
|
|
|
|
2017-06-09 01:41:44 +02:00
|
|
|
class VideoPlayButton extends React.PureComponent {
|
2017-07-01 22:48:12 +02:00
|
|
|
componentDidMount() {
|
2017-07-01 23:57:14 +02:00
|
|
|
this.keyDownListener = this.onKeyDown.bind(this);
|
2017-12-21 22:08:54 +01:00
|
|
|
document.addEventListener('keydown', this.keyDownListener);
|
2017-07-01 23:57:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
2017-12-21 22:08:54 +01:00
|
|
|
document.removeEventListener('keydown', this.keyDownListener);
|
2017-07-01 22:48:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onKeyDown(event) {
|
2017-12-21 22:08:54 +01:00
|
|
|
if (event.target.tagName.toLowerCase() !== 'input' && event.code === 'Space') {
|
2017-07-01 22:48:12 +02:00
|
|
|
event.preventDefault();
|
2017-09-18 04:08:43 +02:00
|
|
|
this.watch();
|
2017-07-01 22:48:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-18 04:08:43 +02:00
|
|
|
watch() {
|
|
|
|
this.props.play(this.props.uri);
|
2017-06-07 07:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-09-08 05:15:05 +02:00
|
|
|
const { button, label, isLoading, fileInfo, mediaType } = this.props;
|
2017-06-07 07:36:12 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
title={
|
|
|
|
isLoading ? "Video is Loading" :
|
|
|
|
!costInfo ? "Waiting on cost info..." :
|
|
|
|
fileInfo === undefined ? "Waiting on file info..." : ""
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2017-07-30 21:57:22 +02:00
|
|
|
const disabled = isLoading || fileInfo === undefined;
|
2017-12-21 22:08:54 +01:00
|
|
|
const icon = ['audio', 'video'].indexOf(mediaType) !== -1 ? 'icon-play' : 'icon-folder-o';
|
2017-06-07 07:36:12 +02:00
|
|
|
|
2017-09-15 15:56:32 +02:00
|
|
|
return (
|
|
|
|
<Link
|
2017-12-21 22:08:54 +01:00
|
|
|
button={button || null}
|
2017-09-15 15:56:32 +02:00
|
|
|
disabled={disabled}
|
2017-12-21 22:08:54 +01:00
|
|
|
label={label || ''}
|
2017-09-15 15:56:32 +02:00
|
|
|
className="video__play-button"
|
|
|
|
icon={icon}
|
2017-09-18 04:08:43 +02:00
|
|
|
onClick={() => this.watch()}
|
2017-09-15 15:56:32 +02:00
|
|
|
/>
|
|
|
|
);
|
2017-06-07 07:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default VideoPlayButton;
|