2024-07-22 11:11:43 +08:00
|
|
|
|
<template>
|
2024-07-24 15:50:24 +08:00
|
|
|
|
<div id="player"></div>
|
2024-07-22 11:11:43 +08:00
|
|
|
|
</template>
|
2024-07-24 15:50:24 +08:00
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import api from '@/axios'
|
2024-07-25 11:40:37 +08:00
|
|
|
|
import { Ref, ref, watch, onMounted, onBeforeMount, onBeforeUnmount, reactive, getCurrentInstance } from 'vue'
|
2024-07-24 15:50:24 +08:00
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const infoData = ref()
|
2024-07-25 11:40:37 +08:00
|
|
|
|
var curIndex = 0 // 当前窗口下标
|
|
|
|
|
let myPlugin: any
|
2024-07-24 15:50:24 +08:00
|
|
|
|
onMounted(() => {
|
2024-07-25 11:40:37 +08:00
|
|
|
|
if (typeof window.JSPlugin === 'undefined') {
|
|
|
|
|
console.error('JSPlugin is not loaded')
|
|
|
|
|
return
|
|
|
|
|
} else {
|
|
|
|
|
console.log('JSPlugin加载成功')
|
2024-07-24 15:50:24 +08:00
|
|
|
|
}
|
2024-07-25 11:40:37 +08:00
|
|
|
|
let date = {
|
|
|
|
|
pointId: router.currentRoute.value.query.pointId,
|
|
|
|
|
useTLS: 0,
|
|
|
|
|
}
|
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
|
date.useTLS = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
api.post('/multialarm/video/preview', { ...date }).then((res) => {
|
2024-07-24 15:50:24 +08:00
|
|
|
|
console.log('router222', res)
|
|
|
|
|
console.log('播放地址', res.data.videoUrl)
|
|
|
|
|
var code = res['code']
|
|
|
|
|
if (code == 0) {
|
|
|
|
|
var playURL = res.data.videoUrl
|
2024-07-29 09:46:35 +08:00
|
|
|
|
// var playURL = 'wss://www.hnjinglian.cn:2563/haikang_play/openUrl/w64vRni'
|
|
|
|
|
|
2024-07-24 15:50:24 +08:00
|
|
|
|
var IS_MOVE_DEVICE = document.body.clientWidth < 992 // 是否移动设备
|
|
|
|
|
var MSE_IS_SUPPORT = !!window.MediaSource // 是否支持mse
|
2024-07-25 11:40:37 +08:00
|
|
|
|
myPlugin = new window.JSPlugin({
|
2024-07-24 15:50:24 +08:00
|
|
|
|
// 当容器div#play_window有固定宽高时,可不传iWidth和iHeight,窗口大小将自适应容器宽高
|
|
|
|
|
// iWidth: 600,
|
|
|
|
|
// iHeight: 400,
|
|
|
|
|
szId: 'player', //需要英文字母开头,唯一性,必填
|
|
|
|
|
szBasePath: './', // 必填,与h5player.min.js的引用目录一致
|
|
|
|
|
iMaxSplit: 1, // 分屏播放,默认最大分屏4*4
|
|
|
|
|
iCurrentSplit: IS_MOVE_DEVICE ? 1 : 2,
|
|
|
|
|
openDebug: true,
|
|
|
|
|
oStyle: {
|
|
|
|
|
borderSelect: IS_MOVE_DEVICE ? '#000' : '#FFCC00',
|
|
|
|
|
},
|
|
|
|
|
bSupporDoubleClickFull: true, //是否支持双击全屏,默认true
|
|
|
|
|
})
|
|
|
|
|
|
2024-07-29 09:46:35 +08:00
|
|
|
|
console.log('myPlugin________', myPlugin)
|
2024-07-25 11:40:37 +08:00
|
|
|
|
|
|
|
|
|
var controlIndex = 2
|
2024-07-24 15:50:24 +08:00
|
|
|
|
function playVideo() {
|
2024-07-25 11:40:37 +08:00
|
|
|
|
console.log('____________playURL:', playURL)
|
|
|
|
|
console.log('____________curIndex:', curIndex)
|
2024-07-24 15:50:24 +08:00
|
|
|
|
// JS_Play 参数说明
|
|
|
|
|
// JS_Play(url, config, windowIndex, startTime, endTime)
|
2024-07-25 11:40:37 +08:00
|
|
|
|
myPlugin
|
2024-07-24 15:50:24 +08:00
|
|
|
|
.JS_Play(
|
|
|
|
|
playURL,
|
|
|
|
|
{
|
|
|
|
|
playURL: playURL, // 流媒体播放时必传
|
|
|
|
|
mode: 1, // 解码类型:0=普通模式; 1=高级模式 默认为0
|
|
|
|
|
},
|
2024-07-25 11:40:37 +08:00
|
|
|
|
curIndex //当前窗口下标
|
2024-07-24 15:50:24 +08:00
|
|
|
|
)
|
|
|
|
|
.then(
|
|
|
|
|
() => {
|
|
|
|
|
console.info('JS_Play success')
|
|
|
|
|
// do you want...
|
|
|
|
|
},
|
2024-07-25 11:40:37 +08:00
|
|
|
|
(e: any) => {
|
|
|
|
|
console.log('网络流中断')
|
|
|
|
|
controlIndex--
|
|
|
|
|
if (controlIndex <= 0) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.info('JS_Play failed:', e)
|
2024-07-24 15:50:24 +08:00
|
|
|
|
playVideo()
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
2024-07-25 11:40:37 +08:00
|
|
|
|
playVideo()
|
2024-07-24 15:50:24 +08:00
|
|
|
|
} else {
|
|
|
|
|
alert('播放失败')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
2024-07-25 11:40:37 +08:00
|
|
|
|
|
|
|
|
|
// 停止播放断开 ws 连接
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
myPlugin.JS_Stop(curIndex).then(
|
|
|
|
|
() => {
|
|
|
|
|
console.info('JS_Stop success')
|
|
|
|
|
// do you want...
|
|
|
|
|
},
|
|
|
|
|
(err: any) => {
|
|
|
|
|
console.info('JS_Stop failed:', err)
|
|
|
|
|
// do you want...
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
})
|
2024-07-22 11:11:43 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
2024-07-24 15:50:24 +08:00
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
#player {
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
background: #000;
|
|
|
|
|
}
|
|
|
|
|
</style>
|