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';
|
2018-06-19 00:16:22 +02:00
|
|
|
import * as icons from 'constants/icons';
|
2018-03-26 23:32:43 +02:00
|
|
|
|
|
|
|
type Props = {
|
2018-05-16 20:32:25 +02:00
|
|
|
play: () => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
isLoading: boolean,
|
|
|
|
mediaType: string,
|
|
|
|
fileInfo: ?{},
|
|
|
|
};
|
|
|
|
|
|
|
|
class VideoPlayButton extends React.PureComponent<Props> {
|
2017-06-07 07:36:12 +02:00
|
|
|
render() {
|
2018-05-16 20:32:25 +02:00
|
|
|
const { fileInfo, mediaType, isLoading, play } = this.props;
|
2018-03-26 23:32:43 +02:00
|
|
|
const disabled = isLoading || fileInfo === undefined;
|
|
|
|
const doesPlayback = ['audio', 'video'].indexOf(mediaType) !== -1;
|
2018-06-19 00:16:22 +02:00
|
|
|
const icon = doesPlayback ? icons.PLAY : icons.EYE;
|
2018-07-09 06:57:31 +02:00
|
|
|
const label = doesPlayback ? __('Play') : __('View');
|
2017-06-07 07:36:12 +02:00
|
|
|
|
2018-05-30 05:18:41 +02:00
|
|
|
return <Button button="primary" disabled={disabled} label={label} icon={icon} onClick={play} />;
|
2017-06-07 07:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default VideoPlayButton;
|