|
@@ -45,6 +45,7 @@
|
|
|
<script>
|
|
|
import rtcPlayer from '../dialog/rtcPlayer.vue'
|
|
|
import PtzControl from "@/components/common/ptzControl";
|
|
|
+import {webrtcEvent} from "@/map/eventMap";
|
|
|
export default {
|
|
|
name: "customPlayer",
|
|
|
components: {
|
|
@@ -72,7 +73,6 @@ export default {
|
|
|
activePlayer: "webRTC",
|
|
|
// 如何你只是用一种播放器,直接注释掉不用的部分即可
|
|
|
player: {
|
|
|
- //jessibuca : ["ws_flv", "wss_flv"],
|
|
|
webRTC: ["rtc", "rtcs"],
|
|
|
},
|
|
|
videoHistory: {
|
|
@@ -114,13 +114,38 @@ export default {
|
|
|
showTimeText: "00:00:00",
|
|
|
streamInfo: null,
|
|
|
enableDebug: true,
|
|
|
+
|
|
|
};
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ // this.showVideoDialog = true;
|
|
|
+ },
|
|
|
methods: {
|
|
|
- playEventHandle(type,message){
|
|
|
+ playEventHandle(type,e){
|
|
|
+ // 添加同类型防抖
|
|
|
+
|
|
|
if(this.enableDebug){
|
|
|
console.log('playEventHandle');
|
|
|
- console.log(type,message);
|
|
|
+ console.log(type,e);
|
|
|
+ }
|
|
|
+ if(type === webrtcEvent.apiFail.code){
|
|
|
+ this.$notify.error({
|
|
|
+ title: 'ZLM连接失败',
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ message: `<span>连接zlm服务失败${e.message}</span> <br/>
|
|
|
+ <a href="${this.videoUrl}" target="_blank"><span>手动访问</span></a>`,
|
|
|
+ duration: 0
|
|
|
+ });
|
|
|
+ this.videoError = true;
|
|
|
+ this.videoUrl = '';
|
|
|
+
|
|
|
+ }else if(type === webrtcEvent.played.code){
|
|
|
+ this.$message.success('播放成功');
|
|
|
+ }else if(type === webrtcEvent.sdpFail.code){
|
|
|
+ this.$notify.error({
|
|
|
+ title: 'sdp 交互失败',
|
|
|
+ duration: 4500
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -159,16 +184,21 @@ export default {
|
|
|
this.hasAudio = hasAudio;
|
|
|
this.isLoging = false;
|
|
|
// this.videoUrl = streamInfo.rtc;
|
|
|
- this.videoUrl = this.getUrlByStreamInfo();
|
|
|
+ this.videoUrl = this.getUrlByStreamInfo(streamInfo);
|
|
|
this.streamId = streamInfo.stream;
|
|
|
this.app = streamInfo.app;
|
|
|
this.mediaServerId = streamInfo.mediaServerId;
|
|
|
this.playFromStreamInfo(false, streamInfo)
|
|
|
},
|
|
|
- playFromStreamInfo: function (realHasAudio, streamInfo) {
|
|
|
+ playFromStreamInfo(realHasAudio, streamInfo) {
|
|
|
this.showVideoDialog = true;
|
|
|
this.hasaudio = realHasAudio && this.hasaudio;
|
|
|
- this.$refs[this.activePlayer].play(this.getUrlByStreamInfo(streamInfo),this.enableDebug)
|
|
|
+ this.videoUrl = this.getUrlByStreamInfo(streamInfo);
|
|
|
+ console.log(this.videoUrl);
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.$refs[this.activePlayer].play(this.videoUrl,this.enableDebug)
|
|
|
+ });
|
|
|
+
|
|
|
},
|
|
|
openDialog: function (tab, deviceId, channelId, param) {
|
|
|
if (this.showVideoDialog) {
|
|
@@ -181,6 +211,7 @@ export default {
|
|
|
this.mediaServerId = "";
|
|
|
this.app = "";
|
|
|
this.videoUrl = ""
|
|
|
+ this.$nextTick(()=>{
|
|
|
if (!!this.$refs[this.activePlayer]) {
|
|
|
this.$refs[this.activePlayer].pause();
|
|
|
}
|
|
@@ -203,6 +234,7 @@ export default {
|
|
|
case "control":
|
|
|
break;
|
|
|
}
|
|
|
+ });
|
|
|
},
|
|
|
getUrlByStreamInfo(){
|
|
|
console.log("获取基础拉流地址")
|
|
@@ -217,37 +249,40 @@ export default {
|
|
|
|
|
|
},
|
|
|
coverPlay: function () {
|
|
|
- var that = this;
|
|
|
+ let that = this;
|
|
|
this.coverPlaying = true;
|
|
|
- this.$refs[this.activePlayer].pause()
|
|
|
- that.$axios({
|
|
|
- method: 'post',
|
|
|
- url: '/api/play/convert/' + that.streamId
|
|
|
- }).then(function (res) {
|
|
|
- if (res.data.code === 0) {
|
|
|
- that.convertKey = res.data.key;
|
|
|
- setTimeout(()=>{
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.$refs[this.activePlayer].pause()
|
|
|
+ that.$axios({
|
|
|
+ method: 'post',
|
|
|
+ url: '/api/play/convert/' + that.streamId
|
|
|
+ }).then(function (res) {
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ that.convertKey = res.data.key;
|
|
|
+ setTimeout(()=>{
|
|
|
+ that.isLoging = false;
|
|
|
+ that.playFromStreamInfo(false, res.data.data);
|
|
|
+ }, 2000)
|
|
|
+ } else {
|
|
|
that.isLoging = false;
|
|
|
- that.playFromStreamInfo(false, res.data.data);
|
|
|
- }, 2000)
|
|
|
- } else {
|
|
|
- that.isLoging = false;
|
|
|
+ that.coverPlaying = false;
|
|
|
+ that.$message({
|
|
|
+ showClose: true,
|
|
|
+ message: '转码失败',
|
|
|
+ type: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).catch(function (e) {
|
|
|
+ console.log(e)
|
|
|
that.coverPlaying = false;
|
|
|
that.$message({
|
|
|
showClose: true,
|
|
|
- message: '转码失败',
|
|
|
+ message: '播放错误',
|
|
|
type: 'error'
|
|
|
});
|
|
|
- }
|
|
|
- }).catch(function (e) {
|
|
|
- console.log(e)
|
|
|
- that.coverPlaying = false;
|
|
|
- that.$message({
|
|
|
- showClose: true,
|
|
|
- message: '播放错误',
|
|
|
- type: 'error'
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
},
|
|
|
convertStopClick: function() {
|
|
|
this.convertStop(()=>{
|