/** * 视频通话页面 */ import React, { Component } from "react"; import { connect } from "dva"; import "./index.less"; import RecordVideo from './RecordVideo'; import { initRecordRTC, stopRecord, startRecord, hasError, downloadRecord } from '../Video/recordRTC'; import { Modal, Checkbox, Space } from 'antd'; import recordingImg from "@assets/images/prevention/aPicture/recording.png"; const { confirm, warning, success, error } = Modal; const _TOOLS = [{ type: 'mute', icon: require("@assets/images/prevention/videobox-volume.png"), checkIcon: require("@assets/images/prevention/videobox-volume-active.png"), name: '静音' },{ type: 'video', icon: require("@assets/images/prevention/videobox-video.png"), checkIcon: require("@assets/images/prevention/videobox-video-active.png"), name: '视频' },{ type: 'add', icon: require("@assets/images/prevention/videobox-add.png"), checkIcon: require("@assets/images/prevention/videobox-add-active.png"), name: '添加' },{ type: 'record', icon: require("@assets/images/prevention/videobox-luzhi.png"), checkIcon: recordingImg, name: '录制' },{ type: 'close', icon: require("@assets/images/prevention/videobox-close.png"), checkIcon: require("@assets/images/prevention/videobox-close-active.png"), name: '结束' }]; const _GENRE_TOOLS = [{ type: 'mute', icon: require("@assets/images/prevention/videobox-volume.png"), checkIcon: require("@assets/images/prevention/videobox-volume-active.png"), name: '静音' },{ type: 'record', icon: require("@assets/images/prevention/videobox-luzhi.png"), checkIcon: recordingImg, name: '录制' },{ type: 'close', icon: require("@assets/images/prevention/videobox-close.png"), checkIcon: require("@assets/images/prevention/videobox-close-active.png"), name: '结束' }]; @connect((state) => ({ ownCid: state.im.v5Data.ownCid, videoType: state.command.videoType, //0: 九宫格 1: 右侧列表 2: 顶部列表 3: 十六宫格 4: 二十五宫格 recordStatus: state.command.recordStatus, // 0:未录制 1:录制中 videoGenre: state.command.videoGenre, // 功能类型 0: 视频调度(一对多) 1: 视频上拉(一对一) })) export default class BoxTool extends Component { constructor(props) { super(props); this.state = { isShowChange: false, // 切换布局弹框是否显示 }; } componentDidMount() { } onClickTool=(type)=>{ const { canMic, common, switchVideoTool, canCamera, addMember, dissolutionRoomModal } = this.props; switch (type) { case "mute":{ if(canMic){ switchVideoTool(type) if (common.isMicOn) { common.isMicOn = false; common.muteAudio(); } else { common.isMicOn = true; common.unmuteAudio(); } } break; } case "video":{ if(canCamera){ switchVideoTool(type); if (common.isCamOn) { common.isCamOn = false; common.muteVideo(); } else { common.isCamOn = true; common.unmuteVideo(); } } break; } case "share":{ common.screenShareClick(); break; } case "add":{ addMember(); break; } case "record":{ this.onRecordVideo('start') break; } case "close":{ dissolutionRoomModal(); } } } onRecordVideo=(status)=>{ // 0:未录制 1:录制中 const that = this; if (status == 'start') { warning({ title: '录制功能为浏览器录制,录制过程中,请勿关闭当前录制的浏览器页面及注意当前网络!', okText: '我知道了', onOk() { Modal.destroyAll() startRecord((success)=>{ that.props.dispatch({ type:'command/fetchRecordStatus', payload: 1 }) }, (err)=>{ error({ title: '浏览器无法获取录制权限,启动失败', okText: '好的', }) }); }, }); } else if(status == 'end') { confirm({ title: '是否确认结束视频调度录屏?', okText: '确定', cancelText: '取消', onOk() { Modal.destroyAll() stopRecord(); that.props.dispatch({ type:'command/fetchRecordStatus', payload: 0 }) const hasE = hasError(); if (hasE) { error({ title: '录制文件生成失败', okText: '好的', }) } else { success({ content: '录制结束,录制文件已下载完成!', okText: '我知道了', onOk(){ Modal.destroyAll() downloadRecord(); } }); } }, onCancel() { console.log('Cancel'); }, }); } this.props.onRecordVideo && this.props.onRecordVideo() } onChangeVideoType(type){ console.log('onChangeVideoType', type); this.props.dispatch({ type:'command/fetchVideoType', payload: type }) } onShowChange(){ this.setState({ isShowChange: this.state.isShowChange ? false : true }) } render() { const { currentTime, isShowChange } = this.state; const { toolStatus, recordStatus, addMember, boxToolStyle, dissolutionRoomModal, videoType, videoGenre } = this.props; const hasVideoScheduling = videoGenre == 0 ? true : false; const tools = hasVideoScheduling ? _TOOLS : _GENRE_TOOLS; return (