|
@@ -1,9 +1,9 @@
|
|
|
<template>
|
|
|
<div class="container-ln">
|
|
|
<customHeader>潞宁新增</customHeader>
|
|
|
- <div class="video-ln">
|
|
|
+ <div class="video-ln" v-if="addrList.length > 0">
|
|
|
<div v-for="(item, index) in addrList" :key="index" class="video-module">
|
|
|
- <div class="player-name">{{ item.name }}</div>
|
|
|
+ <div class="player-name">{{ item.name + index }}</div>
|
|
|
<div style="padding-top:3px">
|
|
|
<template v-if="item.addr.startsWith('rtsp://')">
|
|
|
<video :id="`video${index}`" muted autoplay></video>
|
|
@@ -196,7 +196,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, reactive, onMounted, onUnmounted, shallowRef } from 'vue'
|
|
|
+import { ref, reactive, onMounted, onUnmounted, shallowRef, nextTick } from 'vue'
|
|
|
import customHeader from '/@/components/vent/customHeader.vue';
|
|
|
import GroupMonitorTable from '../comment/GroupMonitorTable.vue';
|
|
|
import MonitorTable from '../comment/MonitorTable.vue';
|
|
@@ -292,7 +292,6 @@ async function getVideoAddrs() {
|
|
|
]
|
|
|
for (let i = 0; i < videoList.length; i++) {
|
|
|
const item = videoList[i];
|
|
|
-
|
|
|
if (item['devicekind'] === 'toHKRtsp') {
|
|
|
// 从海康平台接口获取视频流
|
|
|
try {
|
|
@@ -300,15 +299,9 @@ async function getVideoAddrs() {
|
|
|
if (data) {
|
|
|
cameraList.push({ name: item['name'], addr: data['url'] });
|
|
|
}
|
|
|
- // cameraList.push({
|
|
|
- // name: item['name'],
|
|
|
- // // addr: 'http://219.151.31.38/liveplay-kk.rtxapp.com/live/program/live/hnwshd/4000000/mnf.m3u8'
|
|
|
- // addr: 'https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.mp4/.m3u8',
|
|
|
- // });
|
|
|
} catch (error) {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
if (item['addr'].includes('0.0.0.0')) {
|
|
|
item['addr'] = item['addr'].replace('0.0.0.0', window.location.hostname)
|
|
@@ -317,6 +310,7 @@ async function getVideoAddrs() {
|
|
|
}
|
|
|
}
|
|
|
addrList.value = cameraList
|
|
|
+ getVideo()
|
|
|
}
|
|
|
function goFullScreen(domId) {
|
|
|
const videoDom = document.getElementById(domId) as HTMLVideoElement
|
|
@@ -347,86 +341,29 @@ function clearCamera() {
|
|
|
playerList.value = []
|
|
|
}
|
|
|
function setNoRtspVideo(id, videoAddr) {
|
|
|
- const fileExtension = videoAddr.split('.').pop();
|
|
|
- if (fileExtension === 'flv') {
|
|
|
- const player = new Player({
|
|
|
- lang: 'zh',
|
|
|
- id: id,
|
|
|
- url: videoAddr,
|
|
|
- width: 589,
|
|
|
- height: 330,
|
|
|
- poster: '/src/assets/images/vent/noSinge.png',
|
|
|
- plugins: [FlvPlugin],
|
|
|
- fluid: true,
|
|
|
- autoplay: true,
|
|
|
- isLive: true,
|
|
|
- playsinline: true,
|
|
|
- screenShot: true,
|
|
|
- whitelist: [''],
|
|
|
- ignores: ['time'],
|
|
|
- closeVideoClick: true,
|
|
|
- customConfig: {
|
|
|
- isClickPlayBack: false
|
|
|
- },
|
|
|
- flv: {
|
|
|
- retryCount: 3, // 重试 3 次,默认值
|
|
|
- retryDelay: 1000, // 每次重试间隔 1 秒,默认值
|
|
|
- loadTimeout: 10000, // 请求超时时间为 10 秒,默认值
|
|
|
- fetchOptions: {
|
|
|
- // 该参数会透传给 fetch,默认值为 undefined
|
|
|
- mode: 'cors'
|
|
|
- },
|
|
|
- targetLatency: 10, // 直播目标延迟,默认 10 秒
|
|
|
- maxLatency: 20, // 直播允许的最大延迟,默认 20 秒
|
|
|
- disconnectTime: 10, // 直播断流时间,默认 0 秒,(独立使用时等于 maxLatency)
|
|
|
- maxJumpDistance: 10,
|
|
|
- }
|
|
|
- });
|
|
|
- playerList.value.push(player)
|
|
|
- }
|
|
|
- if (fileExtension === 'm3u8') {
|
|
|
- let player
|
|
|
- if (document.createElement('video').canPlayType('application/vnd.apple.mpegurl')) {
|
|
|
- // 原生支持 hls 播放
|
|
|
- player = new Player({
|
|
|
+ nextTick(() => {
|
|
|
+ const fileExtension = videoAddr.split('.').pop();
|
|
|
+ if (fileExtension === 'flv') {
|
|
|
+ const player = new Player({
|
|
|
lang: 'zh',
|
|
|
id: id,
|
|
|
url: videoAddr,
|
|
|
width: 589,
|
|
|
height: 330,
|
|
|
- isLive: true,
|
|
|
- autoplay: true,
|
|
|
- autoplayMuted: true,
|
|
|
- cors: true,
|
|
|
poster: '/src/assets/images/vent/noSinge.png',
|
|
|
- hls: {
|
|
|
- retryCount: 3, // 重试 3 次,默认值
|
|
|
- retryDelay: 1000, // 每次重试间隔 1 秒,默认值
|
|
|
- loadTimeout: 10000, // 请求超时时间为 10 秒,默认值
|
|
|
- fetchOptions: {
|
|
|
- // 该参数会透传给 fetch,默认值为 undefined
|
|
|
- mode: 'cors'
|
|
|
- },
|
|
|
- targetLatency: 10, // 直播目标延迟,默认 10 秒
|
|
|
- maxLatency: 20, // 直播允许的最大延迟,默认 20 秒
|
|
|
- disconnectTime: 10, // 直播断流时间,默认 0 秒,(独立使用时等于 maxLatency)
|
|
|
- maxJumpDistance: 10,
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- } else if (HlsPlugin.isSupported()) { // 第一步
|
|
|
- player = new Player({
|
|
|
- lang: 'zh',
|
|
|
- id: id,
|
|
|
- url: videoAddr,
|
|
|
- width: 589,
|
|
|
- height: 330,
|
|
|
- isLive: true,
|
|
|
+ plugins: [FlvPlugin],
|
|
|
+ fluid: true,
|
|
|
autoplay: true,
|
|
|
- autoplayMuted: true,
|
|
|
- plugins: [HlsPlugin], // 第二步
|
|
|
- poster: '/src/assets/images/vent/noSinge.png',
|
|
|
- hls: {
|
|
|
+ isLive: true,
|
|
|
+ playsinline: true,
|
|
|
+ screenShot: true,
|
|
|
+ whitelist: [''],
|
|
|
+ ignores: ['time'],
|
|
|
+ closeVideoClick: true,
|
|
|
+ customConfig: {
|
|
|
+ isClickPlayBack: false
|
|
|
+ },
|
|
|
+ flv: {
|
|
|
retryCount: 3, // 重试 3 次,默认值
|
|
|
retryDelay: 1000, // 每次重试间隔 1 秒,默认值
|
|
|
loadTimeout: 10000, // 请求超时时间为 10 秒,默认值
|
|
@@ -439,17 +376,77 @@ function setNoRtspVideo(id, videoAddr) {
|
|
|
disconnectTime: 10, // 直播断流时间,默认 0 秒,(独立使用时等于 maxLatency)
|
|
|
maxJumpDistance: 10,
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
+ playerList.value.push(player)
|
|
|
}
|
|
|
- playerList.value.push(player)
|
|
|
- }
|
|
|
+ if (fileExtension === 'm3u8') {
|
|
|
+ let player
|
|
|
+ if (document.createElement('video').canPlayType('application/vnd.apple.mpegurl')) {
|
|
|
+ // 原生支持 hls 播放
|
|
|
+ player = new Player({
|
|
|
+ lang: 'zh',
|
|
|
+ id: id,
|
|
|
+ url: videoAddr,
|
|
|
+ width: 589,
|
|
|
+ height: 330,
|
|
|
+ isLive: true,
|
|
|
+ autoplay: true,
|
|
|
+ autoplayMuted: true,
|
|
|
+ cors: true,
|
|
|
+ poster: '/src/assets/images/vent/noSinge.png',
|
|
|
+ hls: {
|
|
|
+ retryCount: 3, // 重试 3 次,默认值
|
|
|
+ retryDelay: 1000, // 每次重试间隔 1 秒,默认值
|
|
|
+ loadTimeout: 10000, // 请求超时时间为 10 秒,默认值
|
|
|
+ fetchOptions: {
|
|
|
+ // 该参数会透传给 fetch,默认值为 undefined
|
|
|
+ mode: 'cors'
|
|
|
+ },
|
|
|
+ targetLatency: 10, // 直播目标延迟,默认 10 秒
|
|
|
+ maxLatency: 20, // 直播允许的最大延迟,默认 20 秒
|
|
|
+ disconnectTime: 10, // 直播断流时间,默认 0 秒,(独立使用时等于 maxLatency)
|
|
|
+ maxJumpDistance: 10,
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ } else if (HlsPlugin.isSupported()) { // 第一步
|
|
|
+ player = new Player({
|
|
|
+ lang: 'zh',
|
|
|
+ id: id,
|
|
|
+ url: videoAddr,
|
|
|
+ width: 589,
|
|
|
+ height: 330,
|
|
|
+ isLive: true,
|
|
|
+ autoplay: true,
|
|
|
+ autoplayMuted: true,
|
|
|
+ plugins: [HlsPlugin], // 第二步
|
|
|
+ poster: '/src/assets/images/vent/noSinge.png',
|
|
|
+ hls: {
|
|
|
+ retryCount: 3, // 重试 3 次,默认值
|
|
|
+ retryDelay: 1000, // 每次重试间隔 1 秒,默认值
|
|
|
+ loadTimeout: 10000, // 请求超时时间为 10 秒,默认值
|
|
|
+ fetchOptions: {
|
|
|
+ // 该参数会透传给 fetch,默认值为 undefined
|
|
|
+ mode: 'cors'
|
|
|
+ },
|
|
|
+ targetLatency: 10, // 直播目标延迟,默认 10 秒
|
|
|
+ maxLatency: 20, // 直播允许的最大延迟,默认 20 秒
|
|
|
+ disconnectTime: 10, // 直播断流时间,默认 0 秒,(独立使用时等于 maxLatency)
|
|
|
+ maxJumpDistance: 10,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ playerList.value.push(player)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
getVideoAddrs()
|
|
|
getMonitor(true);
|
|
|
- getVideo()
|
|
|
})
|
|
|
+
|
|
|
onUnmounted(() => {
|
|
|
clearCamera()
|
|
|
if (timer) {
|
|
@@ -481,10 +478,12 @@ onUnmounted(() => {
|
|
|
|
|
|
.video-module {
|
|
|
position: relative;
|
|
|
- width: 45%;
|
|
|
- height: 100%;
|
|
|
+ width: 626px;
|
|
|
+ height: 370px;
|
|
|
+ padding: 17px 18px;
|
|
|
background: url('/@/assets/images/vent/camera_bg.png');
|
|
|
background-size: 100% 100%;
|
|
|
+ margin: 10px;
|
|
|
|
|
|
.player-name {
|
|
|
font-size: 14px;
|