Browse Source

GB视频播放

release_0.0.2
巴林闲侠 3 years ago
parent
commit
efdde52111
  1. 2
      code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperation.jsx
  2. 9
      code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationCloudControl.jsx
  3. 61
      code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx
  4. 3
      code/VideoAccess-VCMP/web/client/src/layout/actions/global.js
  5. 64
      code/VideoAccess-VCMP/web/client/src/layout/reducers/global.js
  6. 15
      code/VideoAccess-VCMP/web/client/src/utils/index.js
  7. 42
      code/VideoAccess-VCMP/web/client/src/utils/videoCloudControl.js
  8. 3
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js
  9. 1
      code/VideoAccess-VCMP/web/config.js
  10. 5
      code/VideoAccess-VCMP/web/routes/attachment/index.js

2
code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperation.jsx

@ -74,7 +74,7 @@ const VideoOperation = ({
/> : '' /> : ''
} }
<div style={{ <div style={{
display: 'flex', justifyContent: 'space-between', display: 'flex', justifyContent: 'space-between', height: '100%'
}}> }}>
{ {
operationState ? operationState ?

9
code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoOperationCloudControl.jsx

@ -1,17 +1,17 @@
import React, { useState, useEffect, useRef } from "react"; import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { ysptz } from '$utils' import { ysptz, gbptz } from '$utils'
import './videoPlay.less'; import './videoPlay.less';
const VideoOperationCloudControl = ({ const VideoOperationCloudControl = ({
videoObj, videoObj, iotVideoServer
}) => { }) => {
const cloudControl = (ac) => { const cloudControl = (ac) => {
if (videoObj.type == 'yingshi') { if (videoObj.type == 'yingshi') {
ysptz(ac, videoObj) ysptz(ac, videoObj)
} else { } else {
gbptz(ac, videoObj, iotVideoServer)
} }
} }
@ -84,9 +84,10 @@ const VideoOperationCloudControl = ({
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { auth } = state; const { auth, global } = state;
return { return {
user: auth.user, user: auth.user,
iotVideoServer: global.iotVideoServer,
}; };
} }

61
code/VideoAccess-VCMP/web/client/src/components/videoPlayer/videoPlay.jsx

@ -2,6 +2,8 @@ import React, { useState, useEffect, useRef } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import screenfull from 'screenfull'; import screenfull from 'screenfull';
import moment from "moment"; import moment from "moment";
import request from 'superagent'
import { VideoServeApi, IotVideoServerRequest } from '$utils'
import VideoHeader from './voiceHeader' import VideoHeader from './voiceHeader'
import VideoOperation from './videoOperation' import VideoOperation from './videoOperation'
import './videoPlay.less'; import './videoPlay.less';
@ -15,7 +17,9 @@ const VideoPlay = ({
height, width, containerId = 'myPlayer', height, width, containerId = 'myPlayer',
// playUrl, // playUrl,
name, name,
// videoObj, // videoObj,
// videoObj = { // videoObj = {
// type: 'yingshi', // type: 'yingshi',
// audio: false, // audio: false,
@ -27,15 +31,19 @@ const VideoPlay = ({
// playUrlHd: 'ezopen://open.ys7.com/G75922040/1.hd.live', // playUrlHd: 'ezopen://open.ys7.com/G75922040/1.hd.live',
// // replayUrl: 'ezopen://open.ys7.com/G75922040/1.rec', // // replayUrl: 'ezopen://open.ys7.com/G75922040/1.rec',
// }, // },
videoObj = { videoObj = {
type: 'cascade', type: 'cascade',
audio: false, audio: false,
serialNo: 'G75922040', // serialNo: '34020000001310000001', //
topSerialNo: 'G75922040', // topSerialNo: '34020000001110000077', //
playUrlSd: 'ws://221.230.55.27:8081/jessica/34020000001110000077/34020000001310000003', // playUrlSd: 'ws://221.230.55.27:8081/jessica/34020000001110000077/34020000001310000001', //
// playUrlHd: 'ezopen://open.ys7.com/G75922040/1.hd.live', // playUrlHd: 'ezopen://open.ys7.com/G75922040/1.hd.live',
// replayUrl: 'ezopen://open.ys7.com/G75922040/1.rec', // replayUrl: 'ezopen://open.ys7.com/G75922040/1.rec',
}, },
//
iotVideoServer
}) => { }) => {
console.log(videoObj); console.log(videoObj);
const [jessibuca, setjessibuca] = useState(null) const [jessibuca, setjessibuca] = useState(null)
@ -211,8 +219,23 @@ const VideoPlay = ({
const createJessibuca = async () => { const createJessibuca = async () => {
if (videoObj.type != 'yingshi') { if (videoObj.type != 'yingshi') {
try {
let $container = document.getElementById('container'); // const inviteRes = await IotVideoServerRequest.get(VideoServeApi.invite, {
// id: '36011200002002021114',
// channel: '36011200581314002900'
// }).then(res => {
// console.log(res);
// }, err => {
// console.log(err);
// })
const inviteRes_ = await request.get(`${iotVideoServer}/api/gb28181/invite?id=${videoObj.topSerialNo}&channel=${videoObj.serialNo}`)
} catch (error) {
console.log(error.response);
}
let $container = document.getElementById(containerId);
const jessibuca = new window.Jessibuca({ const jessibuca = new window.Jessibuca({
container: $container, container: $container,
videoBuffer: 0.2, // videoBuffer: 0.2, //
@ -220,18 +243,18 @@ const VideoPlay = ({
text: "", text: "",
loadingText: "加载中", loadingText: "加载中",
debug: true, debug: true,
showBandwidth: true, // showBandwidth: false, //
operateBtns: { operateBtns: {
fullscreen: true, fullscreen: false,
screenshot: true, screenshot: false,
play: true, play: false,
audio: true, audio: false,
}, },
forceNoOffscreen: false, forceNoOffscreen: false,
isNotMute: false, isNotMute: false,
}); });
setjessibuca(jessibuca) setjessibuca(jessibuca)
play() play({ jessibuca })
} }
} }
@ -240,11 +263,12 @@ const VideoPlay = ({
// setIsPlaying(operation == 'play') // setIsPlaying(operation == 'play')
} }
const play = () => { const play = (params) => {
if (videoObj.type == 'yingshi') { if (videoObj.type == 'yingshi') {
yingshiOperation('play') yingshiOperation('play')
} else if (jessibuca && videoObj.playUrlSd) { } else if ((params.jessibuca || jessibuca) && videoObj.playUrlSd) {
jessibuca.play(videoObj.playUrlSd); const jes = params.jessibuca || jessibuca
jes.play(videoObj.playUrlSd);
setIsPlaying(true) setIsPlaying(true)
} }
} }
@ -276,7 +300,7 @@ const VideoPlay = ({
return ( return (
<> <>
<div className="vcmp_videoplay" style={{ height: height || '100%', width: width || '100%' }}> <div className="vcmp_videoplay" style={{ height: height || '100%', width: width || '100%', overflow: 'hidden' }}>
<div id="vcmp_videoplay" style={{ position: 'relative', display: 'flex', height: '100%', width: '100%' }}> <div id="vcmp_videoplay" style={{ position: 'relative', display: 'flex', height: '100%', width: '100%' }}>
{/* 顶部信息 */} {/* 顶部信息 */}
<VideoHeader <VideoHeader
@ -306,7 +330,8 @@ const VideoPlay = ({
wmode="transparent" wmode="transparent"
style={{ pointerEvents: 'none' }} style={{ pointerEvents: 'none' }}
/> : /> :
<div id="container" <div
id={containerId}
style={{ style={{
height: '100%', width: '100%' height: '100%', width: '100%'
}}> }}>
@ -337,9 +362,11 @@ const VideoPlay = ({
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { auth } = state; const { auth, global } = state;
console.log(global);
return { return {
user: auth.user, user: auth.user,
iotVideoServer: global.iotVideoServer,
}; };
} }

3
code/VideoAccess-VCMP/web/client/src/layout/actions/global.js

@ -37,7 +37,8 @@ export function initApiRoot () {
type: INIT_API_ROOT, type: INIT_API_ROOT,
payload: { payload: {
apiRoot: res.root, apiRoot: res.root,
iotAuthWeb: res.iotAuthWeb iotAuthWeb: res.iotAuthWeb,
iotVideoServer: res.iotVideoServer
} }
}) })
}); });

64
code/VideoAccess-VCMP/web/client/src/layout/reducers/global.js

@ -3,37 +3,41 @@ import Immutable from 'immutable';
import { INIT_LAYOUT, RESIZE, INIT_API_ROOT } from '../actions/global'; import { INIT_LAYOUT, RESIZE, INIT_API_ROOT } from '../actions/global';
function global (state = { function global (state = {
title: '', title: '',
copyright: '', copyright: '',
sections: [], sections: [],
actions: {}, actions: {},
plugins: {}, plugins: {},
clientHeight: 768, clientHeight: 768,
clientWidth: 1024, clientWidth: 1024,
apiRoot: '', apiRoot: '',
iotAuthWeb: '',
iotVideoServer: '',
}, action) { }, action) {
const payload = action.payload; const payload = action.payload;
switch (action.type) { switch (action.type) {
case RESIZE: case RESIZE:
return Immutable.fromJS(state).merge({ return Immutable.fromJS(state).merge({
clientHeight: payload.clientHeight, clientHeight: payload.clientHeight,
clientWidth: payload.clientWidth clientWidth: payload.clientWidth
}).toJS(); }).toJS();
case INIT_LAYOUT: case INIT_LAYOUT:
return Immutable.fromJS(state).merge({ return Immutable.fromJS(state).merge({
title: payload.title, title: payload.title,
copyright: payload.copyright, copyright: payload.copyright,
sections: payload.sections, sections: payload.sections,
actions: payload.actions, actions: payload.actions,
plugins: payload.plugins, plugins: payload.plugins,
}).toJS(); }).toJS();
case INIT_API_ROOT: case INIT_API_ROOT:
return Immutable.fromJS(state).merge({ return Immutable.fromJS(state).merge({
apiRoot: payload.apiRoot, apiRoot: payload.apiRoot,
}).toJS(); iotAuthWeb: payload.iotAuthWeb,
default: iotVideoServer: payload.iotVideoServer,
return state; }).toJS();
} default:
return state;
}
} }
export default global; export default global;

15
code/VideoAccess-VCMP/web/client/src/utils/index.js

@ -1,8 +1,15 @@
'use strict'; 'use strict';
import { isAuthorized } from './func'; import { isAuthorized } from './func';
import { AuthorizationCode } from './authCode'; import { AuthorizationCode } from './authCode';
import { ApiTable, RouteTable, AuthRequest, AxyRequest } from './webapi' import {
import { YS_PTZ_DIRECTION, ysptz } from './videoCloudControl'; ApiTable, VideoServeApi,
RouteTable,
AuthRequest, AxyRequest, IotVideoServerRequest
} from './webapi'
import {
YS_PTZ_DIRECTION, ysptz,
gbptz
} from './videoCloudControl';
export { export {
isAuthorized, isAuthorized,
@ -10,10 +17,14 @@ export {
AuthorizationCode, AuthorizationCode,
ApiTable, ApiTable,
VideoServeApi,
RouteTable, RouteTable,
AuthRequest, AuthRequest,
AxyRequest, AxyRequest,
IotVideoServerRequest,
YS_PTZ_DIRECTION, YS_PTZ_DIRECTION,
ysptz, ysptz,
gbptz,
} }

42
code/VideoAccess-VCMP/web/client/src/utils/videoCloudControl.js

@ -1,5 +1,6 @@
'use strict'; 'use strict';
import superagent from "superagent" import superagent from "superagent"
import { VideoServeApi } from './'
// 操作命令:0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距 // 操作命令:0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距
export const YS_PTZ_DIRECTION = { export const YS_PTZ_DIRECTION = {
@ -51,4 +52,45 @@ export function ysptz (ac, { serialNo, yingshiToken, channelNo }) {
}, 500) }, 500)
} }
}) })
}
export const GB_PTZ_DIRECTION = {
up: 'A50F0108007D003A',
down: 'A50F0104007D0036',
left: 'A50F01027D000034',
right: 'A50F01017D000033',
up_left: 'A50F010A7D7D00B9',
down_left: 'A50F01067D7D00B5',
up_right: 'A50F01097D7D00B8',
down_right: 'A50F01057D7D00B4',
zoom_in: 'A50F012000009065',
zoom_out: 'A50F011000009055',
focus_in: 'A50F0148007D007A',
focus_out: 'A50F0144007D0076',
stop: 'A50F0100000000B5'
}
export function gbptz (ac, { topSerialNo, serialNo }, iotVideoServer) {
let requestUrl = `${iotVideoServer}/${VideoServeApi.control}?id=${topSerialNo}&channel=${serialNo}`
superagent
.get(requestUrl + `&ptzcmd=${GB_PTZ_DIRECTION[ac]}`)
.then((res) => {
console.log(res.status);
if (res.status != '200') {
// message.error(resBody.msg)
} else {
setTimeout(_ => {
superagent
.get(requestUrl + `&ptzcmd=${GB_PTZ_DIRECTION['stop']}`)
.then((tRes) => {
if (tRes.status != '200') {
// message.error('操作失败!')
}
})
}, 500)
}
})
} }

3
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -39,7 +39,8 @@ export const ApiTable = {
}; };
export const VideoServeApi = { export const VideoServeApi = {
invite: 'api/gb28181/invite' invite: 'api/gb28181/invite',
control: 'api/gb28181/control'
} }
export const RouteTable = { export const RouteTable = {

1
code/VideoAccess-VCMP/web/config.js

@ -63,6 +63,7 @@ const product = {
opts: { opts: {
apiUrl: API_URL, apiUrl: API_URL,
iotAuthWeb: IOT_AUTH_WEB, iotAuthWeb: IOT_AUTH_WEB,
iotVideoServer: IOT_VIDEO_SERVER,
staticRoot: './client', staticRoot: './client',
} }
}, { }, {

5
code/VideoAccess-VCMP/web/routes/attachment/index.js

@ -19,12 +19,13 @@ module.exports = {
entry: function (app, router, opts) { entry: function (app, router, opts) {
const getApiRoot = async function (ctx) { const getApiRoot = async function (ctx) {
const { apiUrl, iotAuthWeb } = opts; const { apiUrl, iotAuthWeb, iotVideoServer } = opts;
ctx.status = 200; ctx.status = 200;
ctx.body = { ctx.body = {
root: apiUrl, root: apiUrl,
iotAuthWeb iotAuthWeb,
iotVideoServer
}; };
}; };

Loading…
Cancel
Save