芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/.cache/admin/src/containers/Onboarding/Video.js
/** * * OnboardingList * */ import React from 'react'; import PropTypes from 'prop-types'; import cn from 'classnames'; import { isNaN } from 'lodash'; import { Modal, ModalHeader, ModalBody } from 'reactstrap'; import { Player } from 'video-react'; import 'video-react/dist/video-react.css'; import Li from './Li'; /* eslint-disable */ class OnboardingVideo extends React.Component { componentDidMount() { if (this.hiddenPlayer.current) { this.hiddenPlayer.current.subscribeToStateChange(this.handleChangeState); } } hiddenPlayer = React.createRef(); player = React.createRef(); handleChangeState = (state, prevState) => { const { duration } = state; const { id } = this.props; if (duration !== prevState.duration && !isNaN(duration)) { this.props.setVideoDuration(id, duration); } }; handleChangeIsPlayingState = (state, prevState) => { const { isActive } = state; const { id } = this.props; if (isActive !== prevState.isActive && isActive) { this.props.didPlayVideo(id, this.props.video.startTime); } }; handleCurrentTimeChange = curr => { this.props.getVideoCurrentTime(this.props.id, curr, this.props.video.duration); }; handleModalOpen = () => { this.player.current.subscribeToStateChange(this.handleChangeIsPlayingState); this.player.current.play(); if (this.props.video.startTime === 0) { const { player } = this.player.current.getState(); player.isActive = true; this.props.didPlayVideo(this.props.id, this.props.video.startTime); } else { this.player.current.pause(); } }; handleVideoPause = () => { const { player } = this.player.current.getState(); const currTime = player.currentTime; this.handleCurrentTimeChange(currTime); this.props.didStopVideo(this.props.id, currTime); }; handleModalClose = () => { const { player } = this.player.current.getState(); const paused = player.paused; if (!paused) { this.handleVideoPause(); } }; getVideoTime = (duration, sign) => { const operator = Math.floor(eval(duration + sign + 60)); if (operator < 10) { return `0${operator}`; } return operator; }; render() { const { video } = this.props; const time = isNaN(video.duration) ? '\xA0' : `${Math.floor(video.duration / 60)}:${this.getVideoTime(video.duration, '%')}`; return (
{video.title}
{time}
{video.title}
{!this.props.video.duration && (
)}
); } } OnboardingVideo.defaultProps = { didPlayVideo: () => {}, didStopVideo: () => {}, getVideoCurrentTime: () => {}, id: 0, onClick: () => {}, setVideoDuration: () => {}, video: {}, }; OnboardingVideo.propTypes = { didPlayVideo: PropTypes.func, didStopVideo: PropTypes.func, getVideoCurrentTime: PropTypes.func, id: PropTypes.number, onClick: PropTypes.func, setVideoDuration: PropTypes.func, video: PropTypes.object, }; export default OnboardingVideo;