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

52 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() {
const { button, label, fileInfo, mediaType } = this.props;
/*
title={
isLoading ? "Video is Loading" :
!costInfo ? "Waiting on cost info..." :
fileInfo === undefined ? "Waiting on file info..." : ""
}
*/
const icon = ['audio', 'video'].indexOf(mediaType) !== -1 ? 'icon-play' : 'icon-folder-o';
return (
<Link
button={button || null}
disabled={fileInfo === undefined}
label={label || ''}
className="video__play-button"
icon={icon}
onClick={() => this.watch()}
/>
);
}
}
export default VideoPlayButton;