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

53 lines
1.2 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);
2017-07-01 23:57:14 +02:00
}
componentWillUnmount() {
document.removeEventListener('keydown', this.keyDownListener);
}
onKeyDown(event) {
if (event.target.tagName.toLowerCase() !== 'input' && event.code === 'Space') {
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 || null}
disabled={disabled}
label={label || ''}
className="video__play-button"
icon={icon}
onClick={() => this.watch()}
/>
);
}
}
export default VideoPlayButton;