2018-10-30 05:02:23 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-07-14 19:22:27 +00:00
|
|
|
import React from 'react';
|
2019-03-21 16:38:29 +00:00
|
|
|
|
|
|
|
import { connect } from '../../../redux';
|
2017-07-14 19:22:27 +00:00
|
|
|
import AbstractVideoTrack from '../AbstractVideoTrack';
|
2018-10-30 05:02:23 +00:00
|
|
|
import type { Props as AbstractVideoTrackProps } from '../AbstractVideoTrack';
|
2017-07-14 19:22:27 +00:00
|
|
|
|
2017-08-30 23:58:19 +00:00
|
|
|
import Video from './Video';
|
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link VideoTrack}.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
type Props = AbstractVideoTrackProps & {
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CSS classes to add to the video element.
|
|
|
|
*/
|
|
|
|
className: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The value of the id attribute of the video. Used by the torture tests
|
|
|
|
* to locate video elements.
|
|
|
|
*/
|
2019-10-08 09:34:25 +00:00
|
|
|
id: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Used to determine the value of the autoplay attribute of the underlying
|
|
|
|
* video element.
|
|
|
|
*/
|
2021-01-21 20:46:47 +00:00
|
|
|
_noAutoPlayVideo: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A map of the event handlers for the video HTML element.
|
|
|
|
*/
|
|
|
|
eventHandlers?: {|
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnAbort event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onAbort?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnCanPlay event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onCanPlay?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnCanPlayThrough event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onCanPlayThrough?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnEmptied event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onEmptied?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnEnded event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onEnded?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnError event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onError?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnLoadedData event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onLoadedData?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnLoadedMetadata event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onLoadedMetadata?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnLoadStart event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onLoadStart?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnPause event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onPause?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnPlay event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onPlay?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnPlaying event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onPlaying?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnRateChange event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onRateChange?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnStalled event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onStalled?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnSuspend event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onSuspend?: ?Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* OnWaiting event handler.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
|
|
|
onWaiting?: ?Function,
|
|
|
|
|},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A styles that will be applied on the video element.
|
|
|
|
*/
|
|
|
|
style: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The value of the muted attribute for the underlying element.
|
|
|
|
*/
|
|
|
|
muted?: boolean
|
2018-10-30 05:02:23 +00:00
|
|
|
};
|
|
|
|
|
2017-07-14 19:22:27 +00:00
|
|
|
/**
|
2017-08-31 17:20:44 +00:00
|
|
|
* Component that renders a video element for a passed in video track and
|
|
|
|
* notifies the store when the video has started playing.
|
2017-07-14 19:22:27 +00:00
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments AbstractVideoTrack
|
2017-07-14 19:22:27 +00:00
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
class VideoTrack extends AbstractVideoTrack<Props> {
|
2017-07-14 19:22:27 +00:00
|
|
|
/**
|
|
|
|
* Default values for {@code VideoTrack} component's properties.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static defaultProps = {
|
|
|
|
className: '',
|
|
|
|
|
|
|
|
id: ''
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the video element.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2021-01-21 20:46:47 +00:00
|
|
|
const {
|
|
|
|
_noAutoPlayVideo,
|
|
|
|
className,
|
|
|
|
id,
|
|
|
|
muted,
|
|
|
|
videoTrack,
|
|
|
|
style,
|
|
|
|
eventHandlers
|
|
|
|
} = this.props;
|
|
|
|
|
2017-07-14 19:22:27 +00:00
|
|
|
return (
|
2021-01-21 20:46:47 +00:00
|
|
|
|
2017-08-30 23:58:19 +00:00
|
|
|
<Video
|
2021-01-21 20:46:47 +00:00
|
|
|
autoPlay = { !_noAutoPlayVideo }
|
|
|
|
className = { className }
|
|
|
|
eventHandlers = { eventHandlers }
|
|
|
|
id = { id }
|
|
|
|
muted = { muted }
|
2017-08-30 23:58:19 +00:00
|
|
|
onVideoPlaying = { this._onVideoPlaying }
|
2021-01-21 20:46:47 +00:00
|
|
|
style = { style }
|
|
|
|
videoTrack = { videoTrack } />
|
2017-07-14 19:22:27 +00:00
|
|
|
);
|
|
|
|
}
|
2018-10-30 05:02:23 +00:00
|
|
|
|
|
|
|
_onVideoPlaying: () => void;
|
2017-07-14 19:22:27 +00:00
|
|
|
}
|
|
|
|
|
2019-10-08 09:34:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated VideoTracks props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _noAutoPlayVideo: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
const testingConfig = state['features/base/config'].testing;
|
|
|
|
|
|
|
|
return {
|
|
|
|
_noAutoPlayVideo: testingConfig?.noAutoPlayVideo
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(VideoTrack);
|