admin
2024-02-21 2272213fea7ab9ea6250eefad55bb113ce2b1837
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
  <div style="width: 100%;height: 100%;">
    <div v-if="showId!=''" v-show="imgSXTUrl!=''" style="height: 100%;width: 100%;">
      <video
        :id="'videoElement' + showId"
        controls
        autoplay
        muted
        controlsList="nodownload"
        :disablePictureInPicture="true"
        style="width: 100%; height: 100%; object-fit: contain"
      ></video>
    </div>
    <div v-if="imgSXTUrl==''" style="margin-left: calc(50% - 36px);float: left;margin-top: calc(20% - 5px);color: white;">暂无播放源</div>
  </div>
</template>
 
<script>
import flvjs from "flv.js";
/** 视频信息界面 **/
export default {
  name: 'Index',
  components: {
  },
  props: {
    showId: {
      default: false,
      type: Number
    }
  },
  data() {
    return {
      imgSXTUrl :'',
      lookVideoImgMax: false,
      flvPlayer: {},
    }
  },
  created() {
 
  },
  methods: {
    /** 开始连接摄像头 */
    joinSXT(item) {
      this.closeSXT();
      this.imgSXTUrl=item.playUrl;
      var lookId="videoElement"+ this.showId;
      const that = this;
      if (flvjs.isSupported()) {
        var videoElement = document.getElementById(lookId);
        videoElement.addEventListener("click", mouseHandler, false);
        function mouseHandler(event) {
          event.preventDefault();
        }//这个我是用来防止用户点击,可不加
        that.flvPlayer = flvjs.createPlayer({
          type: "flv",
          url: this.imgSXTUrl,
          //url: 'http://127.0.0.1:8111/flv?port=8112&app=live&stream=test',
          isLive: true,
          hasAudio: false, // 关闭声音
          reuseRedirectedURL: true, //重用301/302重定向url,用于随后的请求,如查找、重新连接等
          // cors: true,
          enableWorker: false, //不启用分离线程
          enableStashBuffer: false, //关闭IO隐藏缓冲区
          autoCleanupSourceBuffer: true, //对SourceBuffer进行自动清理缓存
          autoCleanupMaxBackwardDuration: 12, //    当向后缓冲区持续时间超过此值(以秒为单位)时,请对SourceBuffer进行自动清理
          autoCleanupMinBackwardDuration: 60, //指示进行自动清除时为反向缓冲区保留的持续时间(以秒为单位)。
          stashInitialSize: 128, // 缓存大小(kb)  默认384kb
          fixAudioTimestampGap: false,
        });
        that.flvPlayer.attachMediaElement(videoElement);
        that.flvPlayer.load();
        that.flvPlayer.play(); //不用打开
        this.flvPlayer=that.flvPlayer;
      }
    },
    /** 断开连接摄像头 */
    closeSXT(){
      if(this.imgSXTUrl && this.imgSXTUrl!=''){
        this.imgSXTUrl='';
        if(this.flvPlayer){
          this.flvPlayer.destroy();//销毁实例
        }
      }
    },
  }
}
</script>
 
<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;
 
  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
 
}
.login-index-bod{
  width:100%;
  position:relative;
  height:100%;
  background-color:#fff;
  display:flex;
  flex-direction:row;
  justify-content: center;
  justify-items: center;
  padding-top:13%;
}
 
@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
.selectDivP{
  color: #00c6f0;
}
 
 
//弹框头部
::v-deep .el-dialog__header {
  --el-text-color-primary: #565656;
  --el-text-color-regular: #565656;
  padding: 0 !important;
  width: 100%;
  height: 64px;
  background: linear-gradient(90deg, #565656 0%, #565656 100%);
}
//弹框标题
::v-deep .el-dialog__title {
  margin-left: 24px;
  line-height: 64px;
  color: white;
}
//弹框内容部分
::v-deep .el-dialog__body {
  --el-bg-color: #565656 !important;
  --el-text-color-regular: #565656;
  padding: 0px 0px;
}
 
 
</style>