张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<template>
  <div class="main">
    <div class="main_header">
      <!-- <div class="header_item">
        <span class="header_label">视频名称:</span>
        <el-input v-model="search.videoName" :size="size" clearable placeholder="请输入视频名称"></el-input>
      </div> -->
      <div class="header_item">
        <span class="header_label">视频编码:</span>
        <el-input v-model="search.deviceNum" :size="size" clearable placeholder="请输入视频编码"></el-input>
      </div>
      <!-- <div class="header_item">
        <span class="header_label">视频类别:</span>
        <el-select v-model="search.videoType" placeholder="请选择视频类别" clearable>
            <el-option
                v-for="item in optionsType"
                :key="item.dictId"
                :label="item.dictName"
                :value="item.dictId">
            </el-option>
        </el-select>
      </div> -->
      <div class="header_item">
        <el-button icon="el-icon-search" v-if="showButton('search')" @click="searchButtonInfo(true)">查询</el-button>
        <!-- <el-button class="search_btn" icon="el-icon-plus" v-if="showButton('insert')" @click="insertProp">新增</el-button> -->
      </div>
    </div>
    <div class="main_content" style="overflow: auto;margin: 0 24px 50px;">
        <div class="video_content">
            <div :id="'video_items'+(index+1)" v-for="(item,index) in dataPaths" class="video_item_style" :key="index">
                <!-- <div class="video_names_title">{{item.deviceNum}}</div> -->
            </div>
        </div>
    </div>
    <!-- <div class="main_footer">
      <el-pagination
        background
        @current-change="changePageNum"
        @size-change="changePageSize"
        :current-page="pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div> -->
  </div>
</template>
 
<script>
import  EZUIKit from 'ezuikit-js';
import 'video.js/dist/video-js.min.css'
import "videojs-contrib-hls";
import { buttonPinia } from '../../../pinia/index';
import { changeSize } from '../../../plugins/public'; // 导入节流、动态切换组件尺寸方法
  export default {
    name:'sceneVideo',
    data() {
      return {
        size: changeSize(), // 组件尺寸
        pageNum: 1,
        pageSize: 10,
        logname:false,//获取坐标弹框
        lng:"",//经度
        lat:"",//纬度
        keyword:"",//关键字
        location:"",//地区
        search:{},//查询条件
        total: 0,
        loading: false,
        dataPaths:[],//地址信息
        asyncTitle: true, // 对话框title 新增:true  修改:false
        asyncVisible: false, // 添加 修改对话框
        ruleForm: {
        }, // 按钮表单
        rules: {
          videoSn: [{
            required: true,
            message: '请输入设备ID',
            trigger: 'blur'
          }],
          videoName: [{
            required: true,
            message: '请输入视频名称',
            trigger: 'blur'
          }],
          videoType: [{
            required: true,
            message: '请选择视频类别',
            trigger: 'change'
          }],
          videoPath: [{
            required: true,
            message: '请输入视频地址',
            trigger: 'blur'
          }],
        },
        optionsType:[],//设备类型
        video:null,
        videoConfig:{
            autoplay:true,
            playbackRates: [0.5, 1, 1.5, 2],
            bigPlayButton: false,
            textTrackDisplay: false,
            posterImage: true,
            errorDisplay: false,
            controls: true,
            muted: true,
            preload: 'auto'
        }
      }
    },
    watch: {
      asyncVisible(bol) {
        if(!bol) {
          this.ruleForm = {};
          this.$refs.ruleForm.resetFields();
        }
      }
    },
    mounted() {
      const that = this;
      // 根据窗口大小动态修改组件尺寸
      window.onresize = () => {
        that.size = changeSize();
      }
      that.openFullScreen()
    },
    methods: {
      //销毁初始化
      clearInit(){
        this.dataPaths.forEach((item, index) => {
            let div = document.getElementById(`video_shows${index +1}`)
            div.remove()
        })
      },
      //增加转圈圈
      openFullScreen() {
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        setTimeout(() => {
          loading.close();
        }, 3000);
      },
      // 查询按钮列表信息
      searchButtonInfo(bol) {
        if(bol) {
            this.dataPaths.forEach((item, index) => {
                let div = document.getElementById(`video_shows${index +1}`)
                div.remove()
            })
        }
        let params ={
          types:2,//安全:1;现场:2
        }
        this.dataPaths = []
        this.loading = true;
        this.$api.Device.searchDeviceInfo(params).then((res) => {
          if(res.statusMsg === 'ok') {
            res.data.map(item=>{
                this.dataPaths.push({
                    channelNo:item.channelNo,
                    deviceNum:item.deviceNum,
                    videoPath:item.videoPath,
                })
                return this.dataPaths
            })
            const formData = new FormData();
            formData.set('channelNo', this.dataPaths[0].channelNo);
            formData.set('deviceNum', this.dataPaths[0].deviceNum);
            formData.set('types', 2);
            this.$api.Device.backVideosUrlList(formData).then(resUrl=>{
                this.dataPaths.map(item=>{
                    item.accessToken = resUrl.data
                })
            })
            setTimeout(() => {
                this.showVideo()
            },3000)
          }
          this.loading = false;
          this.openFullScreen()
        })
      },
      //遍历创建视频实例
      showVideo(){
        this.dataPaths.forEach((item,index)=>{
            let name = `video_items${index + 1}`
            this.createVideo(item.videoPath,name,index+1,item.accessToken)
        })
      },
      //视频初始化
      createVideo(url,name,idx,accessToken){
        this.$nextTick(()=>{
            this.createElement(url,name,idx,accessToken)
            // this.video = videojs(`video_shows${idx}`,this.videoConfig)
            this.video = new EZUIKit.EZUIKitPlayer({
                id: `video_shows${idx}`, // 视频容器ID
                accessToken:accessToken,
                url: url,
                height:300,
                audio:0,
                template:'standard',
                header:[],
                fullScreenCallBack:(data) =>console.log(data,'全屏按钮')
                // footer:['fullScreen','hd']
            })
        })
      },
      //创建video标签
      createElement(url,name,idx,accessToken){
        let div = document.getElementById(name)
        let div1 = document.createElement('div')
        div1.id = `video_shows${idx}`
        div1.accessToken = accessToken
        div1.url = url
        // video.classList.add("video-js", "vjs-default-skin", "video")
        // video.classList.add("video-js", "vjs-default-skin", "vjs-big-play-centered")
        // video.style = 'width:100%;height:100%'
        // let source = document.createElement('source')
        // source.src = url
        // source.accessToken = accessToken
        // source.type = 'application/x-mpegURL'
        // video.appendChild(source)
        div.appendChild(div1)
      },
      // 判断按钮权限信息
      showButton(str) {
        const pinia = buttonPinia();
        return pinia.$state.buttonInfo.includes(str);
      },
    },
    // 离开页面后销毁播放器实例
    beforeDestroy() {
        this.video = null
        this.dataPaths.forEach((item, index) => {
            let div = document.getElementById(`video_shows${index +1}`)
            div.remove()
        })
    }
  }
</script>
 
<style lang="scss" scoped>
@import '../../../style/layout-main.scss';
 
.video_content{
    display: flex;
    flex-wrap: wrap;
 
    .video_item_style{
        width: 23.2%;
        height: 300px;
        margin: 0.5%;
        position: relative;
 
        .video_names_title{
            padding-left: 40px;
            position: absolute;
            top: 15px;
            left: 0px;
            z-index: 999;
            color: rgba(255, 255, 255, 1);
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            width: 150px!important;
            display: inline-block;
            &::before{
                content: '';
                width: 18px;
                height: 17px;
                background: url("../../../assets/video_icons.png") no-repeat;
                position: absolute;
                top: 0px;
                left: 10px;
                z-index: 999;
            }
        }
    }
}
 
 
.map-box {
    height: 500px;
    
    .map-search {
        display: flex;
        margin: 10px;
        justify-content: space-between;
        padding: 0 15px;
        
        .label {
            // width: 100px;
            text-align: right;
            color: #fff;
            flex-grow: 0;
            flex-shrink: 0;
        }
        
        .search-item {
            display: flex;
            align-items: center;
        }
    }
}
.get_point{
  /deep/.el-dialog__body{
      overflow: hidden;
  }  
}
::v-deep .el-input .el-input__inner{
  background-color: transparent!important;
  border: 1px solid rgba(49, 105, 215, 0.5)!important;
  color: #fff;
}
</style>