Commit ccdaa90c authored by 程恺文's avatar 程恺文

视频组件发布

parent 463d0e30
......@@ -157,14 +157,17 @@
"cross-spawn": "^7.0.3",
"echarts": "^5.4.0",
"echarts-for-react": "^3.0.2",
"ezuikit-js": "^7.6.3",
"file-loader": "^6.2.0",
"form-render": "^0.9.12",
"highcharts": "^9.0.1",
"highcharts-react-official": "^3.0.0",
"install": "^0.13.0",
"js-export-excel": "^1.1.4",
"jszip": "^3.5.0",
"less": "^3.13.1",
"mqtt-client": "^1.0.12",
"npm": "^9.6.4",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"parseForm": "1.0.0",
"react-redux": "^8.0.5",
......
......@@ -79,7 +79,7 @@ const reportService = {
addReportInfo: {
url: API.ADD_REPORT_INFO,
method: constants.REQUEST_METHOD_POST,
type: constants.REQUEST_METHOD_POST,
type: constants._METHOD_POST,
},
editReportInfo: {
url: API.EDIT_REPORT_INFO,
......
Copyright 2020 dengxiaofeng <1186313486@qq.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
......@@ -29,6 +29,9 @@ group:
| loadingText | 加载过程中文案 | string | "视频加载中" |
| controlAutoHide | 底部控制台是否自动隐藏 | boolean | false |
| recordType | 默认录制的视频格式 | string | mp4 |
| appKey | 萤石EZOPEN账号 | strin |"6c44c8e92d1c4d75a9818756025df550" |
| appSecret | 萤石EZOPEN密码 | strin |"78b7dc88f9f4bf19c2b1aabfdd995244" |
| protocol | 协议类型 | strin |"萤石EZOPEN" |
| operateBtns | 配置操作按钮,以下为 operateBtns 详细属性 | object | |
| | fullscreen 是否显示全屏按钮 | boolean | true |
| | screenshot 是否显示截图按钮 | boolean | true |
......
/*
* @Author: 634665781 634665781@qq.com
* @Date: 2023-04-06 11:18:25
* @LastEditors: 634665781 634665781@qq.com
* @LastEditTime: 2023-04-12 14:29:59
* @FilePath: \ui\src\components\VideoEsy\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import EZUIKit, { log } from 'ezuikit-js';
import React, { useState, useRef, useEffect,useImperativeHandle,forwardRef } from 'react';
import axios from 'axios';
const VideoEsy= (props,ref) => {
const _video1 = useRef(null);
//console.log(props,'props');
const {appKey,appSecret,key} =props.VideoInfo
const [jessibuca,setPlayers] =useState(null)
const getToken = async () =>{
axios.post(`https://open.ys7.com/api/lapp/token/get?appKey=${appKey}&appSecret=${appSecret}`,{},{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(function(response) {
let accessToken= response.data.data.accessToken
let PlayersA= new EZUIKit.EZUIKitPlayer({
id: 'video-container', // 视频容器ID
accessToken: accessToken,
url: `ezopen://open.ys7.com/${key}/1.hd.live`,
})
setPlayers(PlayersA)
useImperativeHandle(
props.Appref,
() =>{
// changeVal 就是暴露给父组件的方法, newVal是父组件传递的参数
return jessibuca // _video&& _video.current&&_video.current.jessibuca
},
)
})
.catch(function(error) {
console.log(error);
});
}
useEffect( ()=>{
getToken()
},[])
return (
<div id="video-container"></div>
)};
const $VideoEsy =forwardRef(VideoEsy)
export default $VideoEsy
// @ts-ignore
import React, { useRef, useEffect } from 'react';
import React, {useRef, useEffect } from 'react';
import Video from '../index';
const Demo1 = (props) => {
const jessibuca = useRef(null);
let JessibucaObj = {
operateBtns: {
// fullscreen: false,
......@@ -20,39 +19,47 @@ const Demo1 = (props) => {
// decoder: window.__POWERED_BY_QIANKUN__ ? '/civbase' + _url : _url
// }
let VideoInfo = {
key: '1CEB209F-8BC7-44B5-9F6B-3D8FCB855E76',
key:'123638446',//'1CEB209F-8BC7-44B5-9F6B-3D8FCB855E76',
dataRate: `/2`,
fullUrl: 'ws://172.16.19.19:8080/jessica/1CEB209F-8BC7-44B5-9F6B-3D8FCB855E76',
useFullUrl: true,
cameraName: `摄像头s8`,
appKey:'6c44c8e92d1c4d75a9818756025df550',
appSecret:'78b7dc88f9f4bf19c2b1aabfdd995244',
protocol:"萤石EZOPEN"
};
useEffect(() => {
// 事件 ,返回视频信息
jessibuca.current.on('videoInfo', function (data) {
jessibuca.current&& jessibuca.current.on('videoInfo', function (data) {
console.log('width:', data.width, 'height:', data.width);
});
// 事件 ,播放视频之后的回调
jessibuca.current.on('play', function (data) {
jessibuca.current&&jessibuca.current.on('play', function (data) {
console.log('play:', jessibuca);
});
// 事件 ,暂停视频之后的回调
jessibuca.current.on('pause', function (data) {
jessibuca.current&&jessibuca.current.on('pause', function (data) {
console.log('pause:', data);
});
// ******
// 其他事件需查看在线文档
// ******
}, []);
const stopVideo = () => {
jessibuca.current.pause();
jessibuca.current.pause&& jessibuca.current.pause()
};
const startVideo = () => {
if (jessibuca && jessibuca.current) {
jessibuca.current.play();
// console.log(jessibuca.current.isPlaying());
......@@ -63,7 +70,8 @@ const Demo1 = (props) => {
};
const destroyVideo = () => {
jessibuca.current.destroy();
if(VideoInfo.protocol !="萤石EZOPEN")jessibuca&&jessibuca.current&&jessibuca.current.destroy();
};
return (
<div>
......@@ -71,7 +79,7 @@ const Demo1 = (props) => {
<button onClick={startVideo}>开始</button>
<button onClick={testVideo}>测试</button>
<button onClick={destroyVideo}>销毁</button>
<Video {...{ JessibucaObj: JessibucaObj, VideoInfo: VideoInfo }} ref={jessibuca} />
<Video {...{ JessibucaObj: JessibucaObj, VideoInfo: VideoInfo }} ref={jessibuca} />
</div>
);
};
......
// eslint-disable-next-line no-unused-vars
import React, { useRef, useEffect, useImperativeHandle, forwardRef } from 'react';
import EZUIKit, { log } from 'ezuikit-js';
import axios from 'axios';
import React, { useState, useRef, useEffect, useImperativeHandle, forwardRef } from 'react';
import App1 from './App';
import style from './index.less';
import VideoEsy from './VideoEsy';
// import * as Jessibuca from './JessibucaVideo/jessibuca';
// proxy.js配置
......@@ -16,6 +19,7 @@ import style from './index.less';
const Video = (props, ref) => {
const _video = useRef(null);
const Players = useRef(null);
const { VideoInfo, JessibucaObj } = props;
let baseUrl = `ws://${window.location.host}/jessica`;
......@@ -26,17 +30,52 @@ const Video = (props, ref) => {
fullUrl: '',
key: `摄像头`,
};
useEffect(() => {
// console.log(_video);
}, []);
const getToken = async () =>{
axios.post(`https://open.ys7.com/api/lapp/token/get?appKey=${VideoInfo.appKey}&appSecret=${VideoInfo.appSecret}`,{},{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(function(response) {
let accessToken= response.data.data.accessToken
let PlayersA= new EZUIKit.EZUIKitPlayer({
id: 'video-container', // 视频容器ID
accessToken: accessToken,
url: `ezopen://open.ys7.com/${VideoInfo.key}/1.hd.live`,
})
PlayersA.pause= PlayersA.stop
ref.current=PlayersA
})
.catch(function(error) {
console.log(error);
});
}
if (VideoInfo.protocol!="萤石EZOPEN"){
useImperativeHandle(
ref,
() =>
// changeVal 就是暴露给父组件的方法, newVal是父组件传递的参数
_video.current.jessibuca,
);
() =>{
// changeVal 就是暴露给父组件的方法, newVal是父组件传递的参数
return _video.current.jessibuca // _video&& _video.current&&_video.current.jessibuca
},
);
}else{
getToken()
}
VideoInfo.url = VideoInfo.useFullUrl ? VideoInfo.fullUrl : baseUrl + VideoInfo.key;
let operateBtns = {
fullscreen: true,
......@@ -55,7 +94,8 @@ const Video = (props, ref) => {
// console.log(_video)
return (
<div className={style.app}>
<App1 {...{ VideoInfo: _VideoInfo, JessibucaObj: JessibucaObj }} ref={_video} />
{VideoInfo.protocol=="萤石EZOPEN"?<div id="video-container"></div>: <App1 {...{ VideoInfo: _VideoInfo, JessibucaObj: JessibucaObj }} ref={_video} />}
</div>
);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment