2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2017-12-21 22:08:54 +01:00
|
|
|
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);
|
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() {
|
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';
|
2017-06-07 07:36:12 +02:00
|
|
|
|
2017-09-15 15:56:32 +02:00
|
|
|
return (
|
2018-03-26 23:32:43 +02:00
|
|
|
<Button
|
|
|
|
button="secondary"
|
|
|
|
disabled={disabled}
|
|
|
|
label={label}
|
2017-09-15 15:56:32 +02:00
|
|
|
icon={icon}
|
2018-03-26 23:32: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;
|