Browse Source

Merge pull request #448 from hotcoffie/wvp-28181-2.0

1.修正了播放地址无法正常播放视频的问题,包含两个错误:
pull/451/head
648540858 3 years ago
committed by GitHub
parent
commit
7f965a6922
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      web_src/src/App.vue
  2. 23
      web_src/src/components/common/jessibuca.vue
  3. 2
      web_src/src/components/dialog/devicePlayer.vue
  4. 512
      web_src/src/components/live.vue
  5. 24
      web_src/src/layout/index.vue
  6. 20
      web_src/src/router/index.js

20
web_src/src/App.vue

@ -81,4 +81,24 @@ body,
text-align: center; text-align: center;
padding-top: 0px !important; padding-top: 0px !important;
} }
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track {
border-radius: 4px;
background-color: #F5F5F5;
}
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: #c8c8c8;
box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
}
</style> </style>

23
web_src/src/components/common/jessibuca.vue

@ -1,5 +1,5 @@
<template> <template>
<div :id="containerId" :ref="containerId" @dblclick="fullscreenSwich"> <div id="container" ref="containerId" @dblclick="fullscreenSwich" style="width: 100%">
<div class="buttons-box" id="buttonsBox"> <div class="buttons-box" id="buttonsBox">
<div class="buttons-box-left"> <div class="buttons-box-left">
<i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i> <i v-if="!playing" class="iconfont icon-play jessibuca-btn" @click="playBtnClick"></i>
@ -44,7 +44,7 @@ export default {
forceNoOffscreen: false, forceNoOffscreen: false,
}; };
}, },
props: ['containerId', 'videoUrl', 'error', 'hasAudio', 'height'], props: ['videoUrl', 'error', 'hasAudio', 'height'],
mounted() { mounted() {
window.onerror = (msg) => { window.onerror = (msg) => {
// console.error(msg) // console.error(msg)
@ -71,19 +71,19 @@ export default {
}, },
methods: { methods: {
updatePlayerDomSize() { updatePlayerDomSize() {
let dom = document.getElementById(this.containerId); let dom = document.getElementById('container');
const width = dom.parentNode.clientWidth const width = dom.parentNode.clientWidth
dom.style.width = width + 'px'; dom.style.width = width + 'px';
dom.style.height = (9 / 16) * width + "px"; dom.style.height = (9 / 16) * width + "px";
}, },
create() { create() {
let options = {}; let options = {};
console.log(this.$refs[this.containerId]) console.log(this.$refs.containerId)
console.log("hasAudio " + this.hasAudio) console.log("hasAudio " + this.hasAudio)
this.jessibuca = new window.Jessibuca(Object.assign( this.jessibuca = new window.Jessibuca(Object.assign(
{ {
container: this.$refs[this.containerId], container: this.$refs.containerId,
videoBuffer: 0.2, // videoBuffer: 0.2, //
isResize: true, isResize: true,
decoder: "static/js/jessibuca/decoder.js", decoder: "static/js/jessibuca/decoder.js",
@ -204,19 +204,6 @@ export default {
}); });
}, },
resize() {
if (this.jessibuca) {
this.jessibuca.resize()
this.$nextTick(() => {
let dom = document.getElementById(this.containerId);
if (dom.parentNode.clientHeight == 0) {
dom.style.height = (9 / 16) * dom.clientWidth + "px"
}
dom.style.height = dom.parentNode.clientHeight + "px";
dom.style.width = dom.parentNode.clientWidth + "px";
})
}
},
playBtnClick: function (event) { playBtnClick: function (event) {
this.play(this.videoUrl) this.play(this.videoUrl)
}, },

2
web_src/src/components/dialog/devicePlayer.vue

@ -4,7 +4,7 @@
<el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()"> <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()">
<!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> --> <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> -->
<div style="width: 100%; height: 100%"> <div style="width: 100%; height: 100%">
<player containerId="container" ref="videoPlayer" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></player> <player ref="videoPlayer" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></player>
</div> </div>
<div id="shared" style="text-align: right; margin-top: 1rem;"> <div id="shared" style="text-align: right; margin-top: 1rem;">
<el-tabs v-model="tabActiveName" @tab-click="tabHandleClick"> <el-tabs v-model="tabActiveName" @tab-click="tabHandleClick">

512
web_src/src/components/live.vue

@ -1,8 +1,8 @@
<template> <template>
<div id="devicePosition" style="width:100vw; height: 91vh"> <div id="devicePosition" style="width:100vw; height: 91vh">
<el-container v-loading="loading" style="height: 91vh;" element-loading-text="拼命加载中" > <el-container v-loading="loading" style="height: 91vh;" element-loading-text="拼命加载中">
<el-aside width="300px" style="background-color: #ffffff"> <el-aside width="300px" style="background-color: #ffffff">
<DeviceTree :clickEvent="clickEvent" :contextMenuEvent="contextMenuEvent" ></DeviceTree> <DeviceTree :clickEvent="clickEvent" :contextMenuEvent="contextMenuEvent"></DeviceTree>
</el-aside> </el-aside>
<el-container> <el-container>
<el-header height="5vh" style="text-align: left;font-size: 17px;line-height:5vh"> <el-header height="5vh" style="text-align: left;font-size: 17px;line-height:5vh">
@ -17,9 +17,8 @@
:style="liveStyle" :class="{redborder:playerIdx == (i-1)}" :style="liveStyle" :class="{redborder:playerIdx == (i-1)}"
@click="playerIdx = (i-1)" @click="playerIdx = (i-1)"
> >
<div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 30px;font-weight: bold;">{{i}}</div> <div v-if="!videoUrl[i-1]" style="color: #ffffff;font-size: 30px;font-weight: bold;">{{ i }}</div>
<player v-else :ref="'player'+i" :videoUrl="videoUrl[i-1]" fluent autoplay :height="true" <player v-else :videoUrl="videoUrl[i-1]" fluent autoplay @screenshot="shot" @destroy="destroy"/>
:containerId="'player'+i" @screenshot="shot" @destroy="destroy"></player>
</div> </div>
</div> </div>
</el-main> </el-main>
@ -29,297 +28,268 @@
</template> </template>
<script> <script>
import uiHeader from "../layout/UiHeader.vue"; import uiHeader from "../layout/UiHeader.vue";
import player from './common/jessibuca.vue' import player from './common/jessibuca.vue'
import DeviceTree from './common/DeviceTree.vue' import DeviceTree from './common/DeviceTree.vue'
export default { export default {
name: "live", name: "live",
components: { components: {
uiHeader, player, DeviceTree uiHeader, player, DeviceTree
}, },
data() { data() {
return { return {
showVideoDialog: true, videoUrl: [''],
hasAudio: false, spilt: 1,//
videoUrl:[''], playerIdx: 0,//
spilt:1,//
playerIdx:0,//
deviceList: [], // updateLooper: 0, //
currentDevice: {}, // count: 15,
total: 0,
videoComponentList: [], //channel
updateLooper: 0, // loading: false
currentDeviceChannelsLenth:0, };
winHeight: window.innerHeight - 200, },
currentPage:1, mounted() {
count:15,
total:0,
getDeviceListLoading: false,
//channel },
searchSrt: "", created() {
channelType: "", this.checkPlayByParam()
online: "", },
channelTotal:0,
deviceChannelList:[],
loading:false
};
},
mounted() {
this.initData();
computed: {
liveStyle() {
if (this.spilt == 1) {
return {width: '100%', height: '100%'}
} else if (this.spilt == 4) {
return {width: '49%', height: '49%'}
} else if (this.spilt == 9) {
return {width: '32%', height: '32%'}
}
}
},
watch: {
spilt(newValue) {
console.log("切换画幅;" + newValue)
let that = this
for (let i = 1; i <= newValue; i++) {
if (!that.$refs['player' + i]) {
continue
}
this.$nextTick(() => {
if (that.$refs['player' + i] instanceof Array) {
that.$refs['player' + i][0].resize()
} else {
that.$refs['player' + i].resize()
}
})
}
window.localStorage.setItem('split', newValue)
}, },
created(){ '$route.fullPath': 'checkPlayByParam'
this.checkPlayByParam() },
destroyed() {
clearTimeout(this.updateLooper);
},
methods: {
destroy(idx) {
console.log(idx);
this.clear(idx.substring(idx.length - 1))
}, },
clickEvent: function (data) {
computed:{ if (data.channelId && data.subCount == 0) {
liveStyle(){ this.sendDevicePush(data)
if(this.spilt==1){
return {width:'100%',height:'100%'}
}else if(this.spilt==4){
return {width:'49%',height:'49%'}
}else if(this.spilt==9){
return {width:'32%',height:'32%'}
}
} }
}, },
watch:{ contextMenuEvent: function (data) {
spilt(newValue){
console.log("切换画幅;"+newValue)
let that = this
for (let i = 1; i <= newValue; i++) {
if(!that.$refs['player'+i]){
continue
}
this.$nextTick(()=>{
if(that.$refs['player'+i] instanceof Array){
that.$refs['player'+i][0].resize()
}else {
that.$refs['player'+i].resize()
}
})
}
window.localStorage.setItem('split',newValue)
},
'$route.fullPath':'checkPlayByParam'
},
destroyed() {
clearTimeout(this.updateLooper);
}, },
methods: { //
destroy(idx) { sendDevicePush: function (itemData) {
console.log(idx); if (itemData.status === 0) {
this.clear(idx.substring(idx.length-1)) this.$message.error('设备离线!');
}, return
clickEvent: function (data) { }
if (data.channelId && data.subCount == 0) { this.save(itemData)
this.sendDevicePush(data) let deviceId = itemData.deviceId;
// this.isLoging = true;
let channelId = itemData.channelId;
console.log("通知设备推流1:" + deviceId + " : " + channelId);
let idxTmp = this.playerIdx
let that = this;
this.loading = true
this.$axios({
method: 'get',
url: '/api/play/start/' + deviceId + '/' + channelId
}).then(function (res) {
// that.isLoging = false;
console.log('=====----=====')
console.log(res)
if (res.data.code == 0 && res.data.data) {
itemData.playUrl = res.data.data.httpsFlv
that.setPlayUrl(res.data.data.ws_flv, idxTmp)
} else {
that.$message.error(res.data.msg);
} }
}, }).catch(function (e) {
contextMenuEvent: function (data) { }).finally(() => {
that.loading = false
});
},
setPlayUrl(url, idx) {
this.$set(this.videoUrl, idx, url)
let _this = this
setTimeout(() => {
window.localStorage.setItem('videoUrl', JSON.stringify(_this.videoUrl))
}, 100)
}, },
// checkPlayByParam() {
sendDevicePush: function (itemData) { let {deviceId, channelId} = this.$route.query
if(itemData.status===0){ if (deviceId && channelId) {
this.$message.error('设备离线!'); this.sendDevicePush({deviceId, channelId})
return }
},
shot(e) {
// console.log(e)
// send({code:'image',data:e})
var base64ToBlob = function (code) {
let parts = code.split(';base64,');
let contentType = parts[0].split(':')[1];
let raw = window.atob(parts[1]);
let rawLength = raw.length;
let uInt8Array = new Uint8Array(rawLength);
for (let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i);
} }
this.save(itemData) return new Blob([uInt8Array], {
let deviceId = itemData.deviceId; type: contentType
// this.isLoging = true;
let channelId = itemData.channelId;
console.log("通知设备推流1:" + deviceId + " : " + channelId );
let idxTmp = this.playerIdx
let that = this;
this.loading = true
this.$axios({
method: 'get',
url: '/api/play/start/' + deviceId + '/' + channelId
}).then(function (res) {
// that.isLoging = false;
console.log('=====----=====')
console.log(res)
if (res.data.code == 0 && res.data.data) {
itemData.playUrl = res.data.data.httpsFlv
that.setPlayUrl(res.data.data.ws_flv,idxTmp)
}else {
that.$message.error(res.data.msg);
}
}).catch(function (e) {
}).finally(()=>{
that.loading = false
}); });
}, };
setPlayUrl(url,idx){ let aLink = document.createElement('a');
this.$set(this.videoUrl,idx,url) let blob = base64ToBlob(e); //new Blob([content]);
let _this = this let evt = document.createEvent("HTMLEvents");
setTimeout(()=>{ evt.initEvent("click", true, true); //initEvent FF
window.localStorage.setItem('videoUrl',JSON.stringify(_this.videoUrl)) aLink.download = '截图';
},100) aLink.href = URL.createObjectURL(blob);
aLink.click();
}, },
checkPlayByParam(){ save(item) {
let {deviceId,channelId} = this.$route.query let dataStr = window.localStorage.getItem('playData') || '[]'
if(deviceId && channelId){ let data = JSON.parse(dataStr);
this.sendDevicePush({deviceId,channelId}) data[this.playerIdx] = item
} window.localStorage.setItem('playData', JSON.stringify(data))
}, },
convertImageToCanvas(image) { clear(idx) {
var canvas = document.createElement("canvas"); let dataStr = window.localStorage.getItem('playData') || '[]'
canvas.width = image.width; let data = JSON.parse(dataStr);
canvas.height = image.height; data[idx - 1] = null;
canvas.getContext("2d").drawImage(image, 0, 0); console.log(data);
return canvas; window.localStorage.setItem('playData', JSON.stringify(data))
}, },
shot(e){ }
// console.log(e) };
// send({code:'image',data:e})
var base64ToBlob = function(code) {
let parts = code.split(';base64,');
let contentType = parts[0].split(':')[1];
let raw = window.atob(parts[1]);
let rawLength = raw.length;
let uInt8Array = new Uint8Array(rawLength);
for(let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i);
}
return new Blob([uInt8Array], {
type: contentType
});
};
let aLink = document.createElement('a');
let blob = base64ToBlob(e); //new Blob([content]);
let evt = document.createEvent("HTMLEvents");
evt.initEvent("click", true, true); //initEvent FF
aLink.download = '截图';
aLink.href = URL.createObjectURL(blob);
aLink.click();
},
save(item){
let dataStr = window.localStorage.getItem('playData') || '[]'
let data = JSON.parse(dataStr);
data[this.playerIdx] = item
window.localStorage.setItem('playData',JSON.stringify(data))
},
clear(idx) {
let dataStr = window.localStorage.getItem('playData') || '[]'
let data = JSON.parse(dataStr);
data[idx-1] = null;
console.log(data);
window.localStorage.setItem('playData',JSON.stringify(data))
},
loadAndPlay(){
let dataStr = window.localStorage.getItem('playData') || '[]'
let data = JSON.parse(dataStr);
data.forEach((item,i)=>{
if(item){
this.playerIdx = i
this.sendDevicePush(item)
}
})
}
}
};
</script> </script>
<style> <style>
.btn{ .btn {
margin: 0 10px; margin: 0 10px;
} }
.btn:hover{
color: #409EFF;
}
.btn.active{
color: #409EFF;
} .btn:hover {
.redborder{ color: #409EFF;
border: 2px solid red !important; }
}
.play-box{ .btn.active {
background-color: #000000; color: #409EFF;
border: 2px solid #505050;
display: flex; }
align-items: center;
justify-content: center; .redborder {
} border: 2px solid red !important;
}
.play-box {
background-color: #000000;
border: 2px solid #505050;
display: flex;
align-items: center;
justify-content: center;
}
</style> </style>
<style> <style>
.videoList { .videoList {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-content: flex-start; align-content: flex-start;
} }
.video-item { .video-item {
position: relative; position: relative;
width: 15rem; width: 15rem;
height: 10rem; height: 10rem;
margin-right: 1rem; margin-right: 1rem;
background-color: #000000; background-color: #000000;
} }
.video-item-img { .video-item-img {
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
margin: auto; margin: auto;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.video-item-img:after { .video-item-img:after {
content: ""; content: "";
display: inline-block; display: inline-block;
position: absolute; position: absolute;
z-index: 2; z-index: 2;
top: 0; top: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
margin: auto; margin: auto;
width: 3rem; width: 3rem;
height: 3rem; height: 3rem;
background-image: url("../assets/loading.png"); background-image: url("../assets/loading.png");
background-size: cover; background-size: cover;
background-color: #000000; background-color: #000000;
} }
.video-item-title { .video-item-title {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
color: #000000; color: #000000;
background-color: #ffffff; background-color: #ffffff;
line-height: 1.5rem; line-height: 1.5rem;
padding: 0.3rem; padding: 0.3rem;
width: 14.4rem; width: 14.4rem;
} }
.baidumap { .baidumap {
width: 100%; width: 100%;
height: 100%; height: 100%;
border: none; border: none;
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
margin: auto; margin: auto;
} }
/* 去除百度地图版权那行字 和 百度logo */ /* 去除百度地图版权那行字 和 百度logo */
.baidumap > .BMap_cpyCtrl { .baidumap > .BMap_cpyCtrl {
display: none !important; display: none !important;
} }
.baidumap > .anchorBL {
display: none !important; .baidumap > .anchorBL {
} display: none !important;
}
</style> </style>

24
web_src/src/layout/index.vue

@ -24,26 +24,6 @@ export default {
} }
</script> </script>
<style> <style>
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track {
border-radius: 4px;
background-color: #F5F5F5;
}
/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: #c8c8c8;
box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
}
/*定义标题栏*/ /*定义标题栏*/
.page-header { .page-header {
background-color: #FFFFFF; background-color: #FFFFFF;
@ -64,10 +44,6 @@ export default {
} }
</style> </style>
<style scoped> <style scoped>
.el-main {
margin: 0;
}
.fade-enter { .fade-enter {
visibility: hidden; visibility: hidden;
opacity: 0; opacity: 0;

20
web_src/src/router/index.js

@ -98,16 +98,6 @@ export default new VueRouter({
name: 'media', name: 'media',
component: media, component: media,
}, },
{
path: '/play/wasm/:url',
name: 'wasmPlayer',
component: wasmPlayer,
},
{
path: '/play/rtc/:url',
name: 'rtcPlayer',
component: rtcPlayer,
},
{ {
path: '/map', path: '/map',
name: 'devicePosition', name: 'devicePosition',
@ -125,5 +115,15 @@ export default new VueRouter({
name: 'deviceTree', name: 'deviceTree',
component: deviceTree, component: deviceTree,
}, },
{
path: '/play/wasm/:url',
name: 'wasmPlayer',
component: wasmPlayer,
},
{
path: '/play/rtc/:url',
name: 'rtcPlayer',
component: rtcPlayer,
},
] ]
}) })

Loading…
Cancel
Save