|
@@ -1,9 +1,21 @@
|
|
<template>
|
|
<template>
|
|
<div id="customPlayer" v-loading="isLoading">
|
|
<div id="customPlayer" v-loading="isLoading">
|
|
- <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="closeHandle()">
|
|
|
|
|
|
+ <el-dialog title="视频播放"
|
|
|
|
+ top="0"
|
|
|
|
+ width="956px"
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
+ :visible.sync="showVideoDialog"
|
|
|
|
+ @close="closeHandle()">
|
|
<div style="width: 100%; height: 100%">
|
|
<div style="width: 100%; height: 100%">
|
|
<rtc-player ref="webRTC" v-if="useActivePlayer === 'webRTC'" @eventCallback="playEventHandle" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></rtc-player>
|
|
<rtc-player ref="webRTC" v-if="useActivePlayer === 'webRTC'" @eventCallback="playEventHandle" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></rtc-player>
|
|
- <mpeg-ts-video ref="flv" v-if="useActivePlayer === 'flv'" ></mpeg-ts-video>
|
|
|
|
|
|
+ <mpeg-ts-video ref="flv"
|
|
|
|
+ :controller="true"
|
|
|
|
+ v-if="useActivePlayer === 'flv'" ></mpeg-ts-video>
|
|
|
|
+ <h265-web-js
|
|
|
|
+ ref="h265"
|
|
|
|
+ :controller="true"
|
|
|
|
+ v-if="useActivePlayer === 'h265'"
|
|
|
|
+ ></h265-web-js>
|
|
</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" >
|
|
@@ -50,6 +62,11 @@
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="contentLine">
|
|
|
|
+ <div class="contentLabel">
|
|
|
|
+ 切换播放格式:
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</el-tab-pane>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
</el-tabs>
|
|
</div>
|
|
</div>
|
|
@@ -58,14 +75,17 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import rtcPlayer from '../dialog/rtcPlayer.vue'
|
|
|
|
import PtzControl from "@/components/common/ptzControl";
|
|
import PtzControl from "@/components/common/ptzControl";
|
|
import {webrtcEvent} from "@/map/eventMap";
|
|
import {webrtcEvent} from "@/map/eventMap";
|
|
// import FlvVideo from "@/components/common/flvVideo.vue";
|
|
// import FlvVideo from "@/components/common/flvVideo.vue";
|
|
|
|
+
|
|
|
|
+import rtcPlayer from '../dialog/rtcPlayer.vue'
|
|
import mpegTsVideo from "@/components/common/mpegtsVideo.vue"
|
|
import mpegTsVideo from "@/components/common/mpegtsVideo.vue"
|
|
|
|
+import H265WebJs from "@/components/common/h265webJs.vue";
|
|
export default {
|
|
export default {
|
|
name: "customPlayer",
|
|
name: "customPlayer",
|
|
components: {
|
|
components: {
|
|
|
|
+ H265WebJs,
|
|
mpegTsVideo,
|
|
mpegTsVideo,
|
|
PtzControl,
|
|
PtzControl,
|
|
rtcPlayer,
|
|
rtcPlayer,
|
|
@@ -98,6 +118,21 @@ export default {
|
|
description: "延迟较低的播放器,需要浏览器支持",
|
|
description: "延迟较低的播放器,需要浏览器支持",
|
|
disable: false
|
|
disable: false
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ key: "flv",
|
|
|
|
+ text: "flv 播放器",
|
|
|
|
+ description: "用于播放flv格式视频,可支持aac音频",
|
|
|
|
+ disable: false
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ key: "h265",
|
|
|
|
+ text: "265 播放器",
|
|
|
|
+ description: "用于播放265格式视频",
|
|
|
|
+ disable: false
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ // mpegTs流
|
|
|
|
+ mpegTs: [
|
|
{
|
|
{
|
|
key: "flv",
|
|
key: "flv",
|
|
text: "flv 播放器",
|
|
text: "flv 播放器",
|
|
@@ -110,7 +145,8 @@ export default {
|
|
// 如何你只是用一种播放器,直接注释掉不用的部分即可
|
|
// 如何你只是用一种播放器,直接注释掉不用的部分即可
|
|
player: {
|
|
player: {
|
|
webRTC: ["rtc", "rtcs"],
|
|
webRTC: ["rtc", "rtcs"],
|
|
- flv: ["flv", "https_flv"],
|
|
|
|
|
|
+ flv: ["ws_flv", "wss_flv"],
|
|
|
|
+ h265: ["ws_flv", "wss_flv"]
|
|
},
|
|
},
|
|
videoHistory: {
|
|
videoHistory: {
|
|
date: '',
|
|
date: '',
|
|
@@ -170,7 +206,6 @@ export default {
|
|
console.log('切换播放器');
|
|
console.log('切换播放器');
|
|
// 暂停旧播放器视频
|
|
// 暂停旧播放器视频
|
|
this.$refs[this.useActivePlayer].pause();
|
|
this.$refs[this.useActivePlayer].pause();
|
|
-
|
|
|
|
this.$nextTick(()=>{
|
|
this.$nextTick(()=>{
|
|
// 使用新播放器打开视频
|
|
// 使用新播放器打开视频
|
|
this.useActivePlayer = activePlayerKey;
|
|
this.useActivePlayer = activePlayerKey;
|
|
@@ -188,7 +223,7 @@ export default {
|
|
clearTimeout(this.playEventHandleTimer);
|
|
clearTimeout(this.playEventHandleTimer);
|
|
}
|
|
}
|
|
this.playEventHandleTimer = setTimeout(()=>{
|
|
this.playEventHandleTimer = setTimeout(()=>{
|
|
- this.webrtcEventExecute(type);
|
|
|
|
|
|
+ this.webrtcEventExecute(type,e);
|
|
},300);
|
|
},300);
|
|
|
|
|
|
},
|
|
},
|
|
@@ -230,6 +265,20 @@ export default {
|
|
hasAudio = this.hasAudio;
|
|
hasAudio = this.hasAudio;
|
|
}
|
|
}
|
|
this.streamInfo = streamInfo;
|
|
this.streamInfo = streamInfo;
|
|
|
|
+
|
|
|
|
+ // 获取 tracks 中的 fps 值
|
|
|
|
+ if(streamInfo.tracks){
|
|
|
|
+ // 根据我们摄像头默认fps值来进行配置播放器
|
|
|
|
+ let fps = 15;
|
|
|
|
+ for (const tracksElement of streamInfo.tracks) {
|
|
|
|
+ if(tracksElement.fps){
|
|
|
|
+ fps = tracksElement.fps;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.fps = fps;
|
|
|
|
+ }
|
|
|
|
+
|
|
this.hasAudio = hasAudio;
|
|
this.hasAudio = hasAudio;
|
|
this.isLoading = false;
|
|
this.isLoading = false;
|
|
// this.videoUrl = streamInfo.rtc;
|
|
// this.videoUrl = streamInfo.rtc;
|
|
@@ -242,11 +291,17 @@ export default {
|
|
},
|
|
},
|
|
playFromStreamInfo(realHasAudio, streamInfo) {
|
|
playFromStreamInfo(realHasAudio, streamInfo) {
|
|
this.showVideoDialog = true;
|
|
this.showVideoDialog = true;
|
|
- this.hasaudio = realHasAudio && this.hasaudio;
|
|
|
|
|
|
+ console.log(realHasAudio);
|
|
|
|
+ // this.hasAudio = realHasAudio && this.hasaudio;
|
|
this.videoUrl = this.getUrlByStreamInfo(streamInfo);
|
|
this.videoUrl = this.getUrlByStreamInfo(streamInfo);
|
|
console.log(this.videoUrl);
|
|
console.log(this.videoUrl);
|
|
this.$nextTick(()=>{
|
|
this.$nextTick(()=>{
|
|
- this.$refs[this.useActivePlayer].play(this.videoUrl,this.enableDebug)
|
|
|
|
|
|
+ this.$refs[this.useActivePlayer].play(
|
|
|
|
+ this.videoUrl,
|
|
|
|
+ this.hasAudio,
|
|
|
|
+ this.fps,
|
|
|
|
+ this.enableDebug
|
|
|
|
+ )
|
|
});
|
|
});
|
|
},
|
|
},
|
|
openDialog: function (tab, deviceId, channelId, param) {
|
|
openDialog: function (tab, deviceId, channelId, param) {
|
|
@@ -286,8 +341,8 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
getUrlByStreamInfo(){
|
|
getUrlByStreamInfo(){
|
|
- console.log("获取基础拉流地址")
|
|
|
|
- console.log(this.streamInfo)
|
|
|
|
|
|
+ console.log("获取基础拉流地址");
|
|
|
|
+ console.log(this.streamInfo);
|
|
let playerData = this.player[this.useActivePlayer];
|
|
let playerData = this.player[this.useActivePlayer];
|
|
if (location.protocol === "https:") {
|
|
if (location.protocol === "https:") {
|
|
this.videoUrl = this.streamInfo[playerData[1]]
|
|
this.videoUrl = this.streamInfo[playerData[1]]
|
|
@@ -335,13 +390,16 @@ export default {
|
|
},
|
|
},
|
|
convertStopClick: function() {
|
|
convertStopClick: function() {
|
|
this.convertStop(()=>{
|
|
this.convertStop(()=>{
|
|
- this.$refs[this.useActivePlayer].play(this.videoUrl)
|
|
|
|
|
|
+ console.log('播放默认格式');
|
|
|
|
+ this.$refs[this.useActivePlayer].play(
|
|
|
|
+ this.videoUrl,
|
|
|
|
+ )
|
|
});
|
|
});
|
|
},
|
|
},
|
|
closeHandle(){
|
|
closeHandle(){
|
|
this.$emit('close')
|
|
this.$emit('close')
|
|
},
|
|
},
|
|
- webrtcEventExecute(type){
|
|
|
|
|
|
+ webrtcEventExecute(type,e){
|
|
// 防抖,防止多次触发
|
|
// 防抖,防止多次触发
|
|
if(type === webrtcEvent.apiFail.code){
|
|
if(type === webrtcEvent.apiFail.code){
|
|
this.$notify.error({
|
|
this.$notify.error({
|
|
@@ -561,4 +619,13 @@ export default {
|
|
.contentLine .contentLabel{
|
|
.contentLine .contentLabel{
|
|
margin-right: 5px;
|
|
margin-right: 5px;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.mx-2{
|
|
|
|
+ margin-left: 2rem;
|
|
|
|
+ margin-right: 2rem;
|
|
|
|
+}
|
|
|
|
+.mx-1{
|
|
|
|
+ margin-left: 1rem;
|
|
|
|
+ margin-right: 1rem;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|