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

45 lines
916 B
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import React from 'react';
2018-03-26 23:32:43 +02:00
import Button from 'component/button';
type Props = {
play: string => void,
isLoading: boolean,
uri: string,
mediaType: string,
fileInfo: ?{},
};
class VideoPlayButton extends React.PureComponent<Props> {
watch: () => void;
constructor() {
super();
this.watch = this.watch.bind(this);
}
watch() {
this.props.play(this.props.uri);
}
render() {
2018-03-26 23:32:43 +02:00
const { fileInfo, mediaType, isLoading } = this.props;
const disabled = isLoading || fileInfo === undefined;
const doesPlayback = ['audio', 'video'].indexOf(mediaType) !== -1;
const icon = doesPlayback ? 'Play' : 'Folder';
const label = doesPlayback ? 'Play' : 'View';
return (
2018-03-26 23:32:43 +02:00
<Button
button="secondary"
disabled={disabled}
label={label}
icon={icon}
2018-03-26 23:32:43 +02:00
onClick={this.watch}
/>
);
}
}
export default VideoPlayButton;