2017-06-07 07:36:12 +02:00
|
|
|
import React from "react";
|
|
|
|
import Link from "component/link";
|
|
|
|
|
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);
|
|
|
|
document.addEventListener("keydown", this.keyDownListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
document.removeEventListener("keydown", this.keyDownListener);
|
2017-07-01 22:48:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onKeyDown(event) {
|
2017-07-02 20:33:07 +02:00
|
|
|
if (
|
|
|
|
"input" !== event.target.tagName.toLowerCase() &&
|
|
|
|
"Space" === event.code
|
|
|
|
) {
|
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-11-24 15:31:05 +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
|
|
|
|
button={button ? button : null}
|
|
|
|
disabled={disabled}
|
|
|
|
label={label ? label : ""}
|
|
|
|
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;
|