Repository URL to install this package:
|
Version:
2.1.16 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const mobx_react_1 = require("xmobx/mobx-react");
const styled_1 = require("./styled");
const VideoState_1 = require("./VideoState");
const renderProps_1 = require("./renderProps");
let Video = class Video extends react_1.default.Component {
constructor() {
super(...arguments); // registering state
this.observableState = this.props.state || new VideoState_1.VideoState(this.props);
}
componentWillMount() {
this.observableState.setIsPlaying(this.props.shouldAutoPlay);
}
render() {
const _a = this.props,
{
className,
state,
renderVideo,
renderControls
} = _a,
remainingProps = tslib_1.__rest(_a, ["className", "state", "renderVideo", "renderControls"]); // getting the toggle play function from observable
const handlePlayPause = this.observableState.toggleIsPlaying;
return react_1.default.createElement(styled_1.VideoPresetWrapper, {
isPlaying: this.observableState.isPlaying,
className: className,
onClick: handlePlayPause
}, renderVideo(remainingProps, this.observableState), renderControls(remainingProps, this.observableState));
}
}; // props
Video.defaultProps = {
src: [''],
title: 'Video Title',
slogan: 'Video Description Line 1',
shareTitle: 'Share',
videoLength: '00:00',
shouldShowVideoInformation: true,
hasPlayButton: true,
renderVideo: renderProps_1.defaultRenderVideo,
renderControls: renderProps_1.defaultRenderControls
};
Video = tslib_1.__decorate([mobx_react_1.observer], Video);
exports.Video = Video;
exports.default = Video;