lbry-desktop/src/renderer/js/component/video/internal/play-button.jsx

59 lines
1.3 KiB
React
Raw Normal View History

import React from "react";
import Link from "component/link";
2017-06-09 01:41:44 +02:00
class VideoPlayButton extends React.PureComponent {
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);
}
onKeyDown(event) {
if (
"input" !== event.target.tagName.toLowerCase() &&
"Space" === event.code
) {
event.preventDefault();
this.watch();
}
}
watch() {
this.props.play(this.props.uri);
}
render() {
2017-09-08 05:15:05 +02:00
const { button, label, isLoading, fileInfo, mediaType } = this.props;
/*
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;
const icon =
["audio", "video"].indexOf(mediaType) !== -1
? "icon-play"
: "icon-folder-o";
return (
<Link
button={button ? button : null}
disabled={disabled}
label={label ? label : ""}
className="video__play-button"
icon={icon}
onClick={() => this.watch()}
/>
);
}
}
export default VideoPlayButton;