Browse Source

修改

master
wangxingyuan 5 months ago
parent
commit
519df2e281
5 changed files with 1634 additions and 18 deletions
  1. +1261
    -0
      src/components/VideoPlayerPlatform/index.vue
  2. +127
    -0
      src/components/VideoPlayerPlatform/players/jessibucaPlayer.js
  3. +69
    -0
      src/components/VideoPlayerPlatform/players/livePlayer.vue
  4. +132
    -0
      src/components/VideoPlayerPlatform/players/zlmRtcPlayer.js
  5. +45
    -18
      src/views/point/site_management.vue

+ 1261
- 0
src/components/VideoPlayerPlatform/index.vue
File diff suppressed because it is too large
View File


+ 127
- 0
src/components/VideoPlayerPlatform/players/jessibucaPlayer.js View File

@ -0,0 +1,127 @@
/**
* 播放器类
*/
class JessibucaPlayer {
//初始化 可以 await
init () {
const me = this
return new Promise((resolve) => {
me.jessibuca = new window.Jessibuca(this.config);
me.jessibuca.on("load", function () {
resolve()
});
//网速信息
me.jessibuca.on('kBps', function (kBps) {
if (me.config['onkBps']) {
me.config['onkBps'](kBps);
}
});
//错误信息
me.jessibuca.on('error', function (error) {
if (me.config['onError']) {
me.config['onError'](error);
}
});
//码流信息
me.jessibuca.on("stats", function (stats) {
if (me.config['onStats']) {
me.config['onStats'](stats);
}
})
//性能
/**
* 0: 表示卡顿
* 1: 表示流畅
* 2: 表示非常流畅
* 这个可以供ui来显示用
*/
me.jessibuca.on("performance", function (performance) {
if (me.config['onPerformance']) {
me.config['onPerformance'](performance);
}
})
//超时事件
me.jessibuca.on("timeout", function () {
if (me.config['onTimeout']) {
me.config['onTimeout']();
}
})
})
}
// 播放
play (url, cb) {
this.jessibuca.on("play", () => {
cb && cb()
});
if (this.jessibuca.hasLoaded()) {
this.jessibuca.play(url);
} else {
this.jessibuca.on("load", () => {
this.jessibuca.play(url);
});
}
}
//取消静音
cancelMute () {
this.jessibuca.cancelMute()
}
//销毁
destroy () {
this.jessibuca.destroy()
}
//全屏
setFullscreen () {
this.jessibuca.setFullscreen()
}
//截图
screenshot () {
this.jessibuca.screenshot()
}
//重置画面
resize(){
this.jessibuca.resize();
}
constructor(options) {
this.config = Object.assign({
container: null,//播放容器element
videoBuffer: 0.2,//设置最大缓冲时长,单位毫秒,播放器会自动消除延迟。
vod: false,
isResize: true,//当为true的时候:视频画面做等比缩放后,高或宽对齐canvas区域,画面不被拉伸,但有黑边。当为false的时候:视频画面完全填充canvas区域,画面会被拉伸。
isFullSize: false,// 当为true的时候:视频画面做等比缩放后,完全填充canvas区域,画面不被拉伸,没有黑边,但画面显示不全。
isFlv: false,//当为true的时候:ws协议不检验是否以.flv为依据,进行协议解析。
debug: false,
timeout: 30,// 超时时间
supportDblclickFullscreen: true,//双击全屏
showBandwidth: false, //显示网速
keepScreenOn: false,//保持屏幕
isNotMute: false,//是否开启声音,默认是关闭声音播放的。
hasAudio: true,//是否包含音频
/**
* fullscreen 是否显示全屏按钮
* screenshot 是否显示截图按钮
* play 是否显示播放暂停按钮
* audio 是否显示声音按钮
*/
operateBtns: {
fullscreen: false,
screenshot: false,
play: false,
audio: false
},
loadingText: '加载中...',//加载过程中文案。
background: '',//背景图片。
/*
* worker地址
* 直接引用 index.js 的地址即可项目会直接引用根目录的index.js如果修改了index.js文件名称改为xxx.js
* 请同步修改decoder参数引用的是xxx.js文件目录
*/
decoder: 'index.js',
rotate: 0,//设置旋转角度,只支持,0(默认) ,180,270 三个值。
text: '',
forceNoOffscreen: true,// 是否不使用离屏模式(提升渲染能力)
hiddenAutoPause: false//是否开启当页面的'visibilitythis.变为'hidden'的时候,自动暂停播放。
}, options)
}
}
export default JessibucaPlayer

+ 69
- 0
src/components/VideoPlayerPlatform/players/livePlayer.vue View File

@ -0,0 +1,69 @@
<template>
<LivePlayer v-show="visible" :show-custom-button="false" ref="player" @snapOutside="onSnap" aspect='fullscreen' :videoUrl="videoUrl" :live="true" :alt="' '" :hide-fluent-button="true" :hide-big-play-button="true" @pause="onpause" @ended="onended" @timeupdate="ontimeupdate" />
</template>
<script>
import LivePlayer from '@liveqing/liveplayer'
export default {
data () {
return {
visible: false,
videoUrl: ''
}
},
components: {
LivePlayer
},
methods: {
onpause () {
this.$emit('pause')
},
ontimeupdate (t) {
this.$emit('timeupdate', t)
},
onended () {
this.$emit('ended')
},
onSnap (str) {
this.$emit('snap', str)
},
show () {
this.visible = true
},
hide () {
this.visible = false;
},
play (url, time) {
if (url) {
this.videoUrl = url
}
this.$refs.player.play()
if (time) {
this.$refs.player.setCurrentTime(time);
}
},
replay () {
this.$refs.player.play()
},
destroy () {
this.videoUrl = ''
},
setFullscreen () {
this.$refs.player.toggleFullscreen()
},
setMuted (open) {
this.$refs.player.setMuted(open ? 0 : 1)
},
snap () {
this.$refs.player.snap()
},
pause () {
this.$refs.player.pause()
}
}
}
</script>
<style lang="scss">
.video-wrapper .alt {
display: none;
}
</style>

+ 132
- 0
src/components/VideoPlayerPlatform/players/zlmRtcPlayer.js View File

@ -0,0 +1,132 @@
class ZlmRtcPlayer {
constructor(options) {
this.webrtcPlayer = null;
this.playerEl = null;
this.config = Object.assign({
debug: false,
simulecast: false,
useCamera: false,
audioEnable: false,
videoEnable: false,
recvOnly: true,
}, options)
}
eventcallbacK (e, msg) {
if (this.config['on' + e]) {
this.config['on' + e](msg);
}
}
//全屏
setFullscreen () {
// this.playerEl.setFullscreen()
const el = this.playerEl;
function launchFullScreen () {
var element = el;
if (element.requestFullScreen) {
element.requestFullScreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}
launchFullScreen();
}
setMuted (open) {
this.playerEl.volume = open ? 1 : 0;
}
setVolume (val) {
this.playerEl.volume = val;
}
getVideoSize(){
let height = this.playerEl.videoHeight
let width = this.playerEl.videoWidth
return {
width,height
}
}
snap (cb) {
let canvas = document.createElement('canvas');
canvas.setAttribute('width', this.playerEl.videoWidth);
canvas.setAttribute('height', this.playerEl.videoHeight);
var ctx = canvas.getContext("2d");
ctx.drawImage(this.playerEl, 0, 0, canvas.width, canvas.height);
canvas.toBlob(function (blob) {
canvas = null;
cb(blob)
});
}
destroy () {
this.webrtcPlayer.close();
this.playerEl.remove();
}
init () {
return new Promise((resolve) => {
resolve();
})
}
resize () { }
pause(){
this.playerEl.pause()
}
replay(){
this.playerEl.play()
}
play (url) {
// console.log(url,"play预置位配置url")
var ZLMRTCClient = window.ZLMRTCClient;
const player = document.createElement('video');
this.playerEl = player;
const me = this
// player.setAttribute('controls', 'controls');
player.setAttribute('autoplay', 'autoplay');
player.setAttribute('playsinline', 'playsinline');
player.setAttribute('stretch', 'stretch');
player.setAttribute('crossorigin', 'anonymous');
player.addEventListener('pause', () => {
me.eventcallbacK("pause", "暂停")
})
player.classList.add('video_player_zlm')
// player.setAttribute('id', 'v_' + this.config.container.id);
this.config.container.innerHtml = '';
this.config.container.appendChild(player);
this.webrtcPlayer = new ZLMRTCClient.Endpoint({
element: player,// video 标签
debug: this.config.debug,// 是否打印日志
zlmsdpUrl: url,//流地址
// zlmsdpUrl:document.location.protocol+"//"+window.location.host + "/wuhan/videoMonitor2/index/api/webrtc?app=live&stream=stream"+"&type=play",
simulecast: this.config.simulecast,
useCamera: this.config.useCamera,
audioEnable: this.config.audioEnable,
videoEnable: this.config.videoEnable,
recvOnly: this.config.recvOnly,
})
this.webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR, () => {// ICE 协商出错
// console.error('ICE 协商出错', e)
this.eventcallbacK("ICE ERROR", "ICE 协商出错")
});
this.webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS, (stream) => {//获取到了远端流,可以播放
console.log(stream)
player.volume = 0;
this.eventcallbacK("playing", "播放成功")
});
this.webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, (e) => {// offer anwser 交换失败
// console.error('offer anwser 交换失败', e)
this.eventcallbacK("OFFER ANSWER ERROR", "offer anwser 交换失败")
if (e.code == -400 && e.msg == "流不存在") {
this.timer = setTimeout(() => {
this.webrtcPlayer.close();
this.play(url);
}, 100)
}
});
this.webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_LOCAL_STREAM, () => {// 获取到了本地流
this.eventcallbacK("LOCAL STREAM", "获取到了本地流")
});
}
}
export default ZlmRtcPlayer

+ 45
- 18
src/views/point/site_management.vue View File

@ -26,7 +26,7 @@
</el-col> </el-col>
<el-col :span="14"> <el-col :span="14">
<el-alert <el-alert
:title="$t('share.prompt')"
title="提示"
type="info" type="info"
:description="$t('site_management.promptMsg') + ';'" :description="$t('site_management.promptMsg') + ';'"
show-icon show-icon
@ -123,14 +123,14 @@
:render-header="addRedStar" :render-header="addRedStar"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ patrolTypeNameFn(scope.row.patrolTypeIds) }}
<el-select <el-select
multiple multiple
v-model="scope.row.patrolTypeId"
v-model="scope.row.patrolTypeIds"
:placeholder=" :placeholder="
$t('share.PleaseChoose') + $t('share.PleaseChoose') +
$t('site_management.InspectionType') $t('site_management.InspectionType')
" "
disabled
> >
<el-option <el-option
v-for="item in InspectionTypeData" v-for="item in InspectionTypeData"
@ -379,10 +379,9 @@
prop="patrolTypeId" prop="patrolTypeId"
> >
<el-select <el-select
v-model="monitorPointForm.patrolTypeId"
v-model="monitorPointForm.patrolTypeIds"
multiple multiple
filterable filterable
allow-create
default-first-option default-first-option
:placeholder=" :placeholder="
$t('share.PleaseChoose') + $t('site_management.InspectionType') $t('share.PleaseChoose') + $t('site_management.InspectionType')
@ -784,11 +783,14 @@ import {
// listByEqIdAndChannelId // listByEqIdAndChannelId
} from "@/api/point/site_management"; } from "@/api/point/site_management";
import siteVideoDialog from "./components/site_VideoDialog.vue"; import siteVideoDialog from "./components/site_VideoDialog.vue";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default { export default {
name: "SiteManagement", name: "SiteManagement",
components: { components: {
videoPlayer, videoPlayer,
siteVideoDialog, siteVideoDialog,
Treeselect,
}, },
data() { data() {
return { return {
@ -919,6 +921,7 @@ export default {
}), }),
getPatroltypeList().then((res) => { getPatroltypeList().then((res) => {
if (res.code == 200) { if (res.code == 200) {
console.log(res.rows, 1111111111);
this.InspectionTypeData = res.rows; this.InspectionTypeData = res.rows;
} }
}); });
@ -954,6 +957,12 @@ export default {
if (res.code == 200) { if (res.code == 200) {
this.tableData = res.rows; this.tableData = res.rows;
this.tableData.forEach((item) => { this.tableData.forEach((item) => {
// item.patrolTypeIds = item.patrolTypeId.split(",");
// item.patrolTypeIds = item.patrolTypeId.split(",").map(Number)||[];
item.patrolTypeIds = (item.patrolTypeId || "")
.split(",")
.map(Number)
.filter(Boolean);
let id = item.algSubtypeIds.split(","); let id = item.algSubtypeIds.split(",");
item.patrolTypeId = id.map(Number); item.patrolTypeId = id.map(Number);
}); });
@ -991,6 +1000,7 @@ export default {
}, },
tabsClick() {}, tabsClick() {},
add() { add() {
this.monitorPointForm={}
this.type = 0; this.type = 0;
this.monitorPointDialogVisible = true; this.monitorPointDialogVisible = true;
this.monitorPointTitle = this.$t("site_management.AddMonitoringPoints"); this.monitorPointTitle = this.$t("site_management.AddMonitoringPoints");
@ -999,20 +1009,16 @@ export default {
this.monitorPointDialogVisible = false; this.monitorPointDialogVisible = false;
}, },
monitorPointEdit(data) { monitorPointEdit(data) {
this.monitorPointForm={}
this.type = 1; this.type = 1;
this.monitorPointDialogVisible = true; this.monitorPointDialogVisible = true;
this.monitorPointTitle = this.$t( this.monitorPointTitle = this.$t(
"site_management.ModifyMonitoringPoints" "site_management.ModifyMonitoringPoints"
); );
this.monitorPointForm = data;
// this.tableData.forEach((item) => {
// if (item.patrolpointId == data.patrolpointId) {
// // console.log(item, 11111111111111);
// editItem(item.patrolpointId).then((res) => {
// console.log(res, 111111111);
// });
// }
// });
this.monitorPointForm = {
...data,
patrolTypeIds: data.patrolTypeIds || [],
};
}, },
// //
bindingMonitorPointClose() { bindingMonitorPointClose() {
@ -1052,9 +1058,9 @@ export default {
InspectionBtn() { InspectionBtn() {
this.InspectionDialogVisible = true; this.InspectionDialogVisible = true;
eqpbookList(this.eqpbookListQuery).then((res) => { eqpbookList(this.eqpbookListQuery).then((res) => {
console.log(res,1111)
if(res.code==200){
this.InspectionTableData=res.rows
console.log(res, 1111);
if (res.code == 200) {
this.InspectionTableData = res.rows;
} }
}); });
}, },
@ -1094,7 +1100,7 @@ export default {
this.$refs["ruleForm"].validate((valid) => { this.$refs["ruleForm"].validate((valid) => {
if (valid) { if (valid) {
this.monitorPointForm.patrolTypeId = this.monitorPointForm.patrolTypeId =
this.monitorPointForm.patrolTypeId.toString();
this.monitorPointForm.patrolTypeIds.toString();
if (this.type == 0) { if (this.type == 0) {
postAdd(this.monitorPointForm).then((res) => { postAdd(this.monitorPointForm).then((res) => {
if (res.code == 200) { if (res.code == 200) {
@ -1190,6 +1196,27 @@ export default {
dialogChannelImgHandleClose() { dialogChannelImgHandleClose() {
this.dialogChannelImg = false; this.dialogChannelImg = false;
}, },
patrolTypeNameFn(arr) {
// console.log(str, 1111111111);
if (Array.isArray(arr) && arr.length > 0) {
// return this.InspectionTypeData.filter(item => item.id == str)[0].name;
console.log(this.InspectionTypeData, "存在", arr);
}
},
// handleSelectPointCode(node, row) {
// row.patrolTypeId.push(node.id);
// console.log( row.patrolTypeId,2222222)
// return
// this.handleChangePointCode(row);
// },
// handleDeSelectPointCode(node, row) {
// if (row.patrolTypeId.indexOf(node.id) != -1) {
// row.patrolTypeId.splice(row.patrolTypeId.indexOf(node.id), 1);
// console.log( row.patrolTypeId,2222222)
// return
// this.handleChangePointCode(row);
// }
// },
}, },
}; };
</script> </script>


Loading…
Cancel
Save