视频问题修改

This commit is contained in:
libingtao 2024-07-26 16:19:43 +08:00
parent 7038e38809
commit e4986834f2
3 changed files with 103 additions and 117 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,123 +1,109 @@
<template>
<div id="player"></div>
<div id="player"></div>
</template>
<script lang="ts" setup>
import api from '@/axios'
import { Ref, ref, watch, onMounted, onBeforeMount, onBeforeUnmount, reactive, getCurrentInstance } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const infoData = ref()
var curIndex = 0 //
let myPlugin: any
onMounted(() => {
if (typeof window.JSPlugin === 'undefined') {
console.error('JSPlugin is not loaded')
return
} else {
console.log('JSPlugin加载成功')
}
let date = {
pointId: router.currentRoute.value.query.pointId,
useTLS: 0,
}
if (process.env.NODE_ENV === 'production') {
date.useTLS = 1
}
import api from '@/axios'
import { Ref, ref, watch, onMounted, onBeforeMount, onBeforeUnmount, reactive, getCurrentInstance } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const infoData = ref()
var curIndex = 0 //
let myPlugin : any
onMounted(() => {
if (typeof window.JSPlugin === 'undefined') {
return
} else {
}
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) => {
console.log('router222', res)
console.log('播放地址', res.data.videoUrl)
var code = res['code']
if (code == 0) {
var playURL = res.data.videoUrl
var IS_MOVE_DEVICE = document.body.clientWidth < 992 //
var MSE_IS_SUPPORT = !!window.MediaSource // mse
myPlugin = new window.JSPlugin({
// div#play_windowiWidthiHeight
// 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
})
myPlugin
.JS_SetWindowControlCallback({
pluginErrorHandler: function (index: any, iErrorCode: any, oError: any) {
console.error('__________pluginErrorHandler错误码________________', index, iErrorCode, oError)
api.post('/multialarm/video/preview', { ...date }).then((res) => {
// console.log('router222', res)
console.log('播放地址', res.data.videoUrl)
var code = res['code']
if (code == 0) {
var playURL = res.data.videoUrl
// var playURL = 'wss://w.hnjinglian.cn:2563/haikang play/openUrl/w64vRni'
var IS_MOVE_DEVICE = document.body.clientWidth < 992 //
var MSE_IS_SUPPORT = !!window.MediaSource // mse
myPlugin = new window.JSPlugin({
// div#play_windowiWidthiHeight
// 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
})
myPlugin.JS_SetWindowControlCallback({
pluginErrorHandler: function (index : any, iErrorCode : any, oError : any) {
//
// do you want...
//
//
},
})
.then((res: any) => {
console.log('JS_SetWindowControlCallback________________', res)
})
},
})
.then((res : any) => {
})
var controlIndex = 2
function playVideo() {
console.log('____________playURL:', playURL)
console.log('____________curIndex:', curIndex)
// JS_Play
// JS_Play(url, config, windowIndex, startTime, endTime)
myPlugin
.JS_Play(
playURL,
{
playURL: playURL, //
mode: 1, // 0=; 1= 0
},
curIndex //
)
.then(
() => {
console.info('JS_Play success')
// do you want...
},
(e: any) => {
console.log('网络流中断')
controlIndex--
if (controlIndex <= 0) {
return
}
console.info('JS_Play failed:', e)
playVideo()
}
)
}
playVideo()
} else {
alert('播放失败')
}
})
})
var controlIndex = 2
function playVideo() {
myPlugin
.JS_Play(
playURL,
{
playURL: playURL, //
mode: 1, // 0=; 1= 0
},
curIndex //
)
.then(
() => {
},
(e : any) => {
// console.log('')
controlIndex--
if (controlIndex <= 0) {
return
}
// console.info('JS_Play failed:', e)
playVideo()
}
)
}
playVideo()
} else {
alert('播放失败')
}
})
})
// 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...
}
)
})
// 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...
}
)
})
</script>
<style scoped lang="scss">
#player {
height: 100%;
width: 100%;
background: #000;
}
#player {
height: 100%;
width: 100%;
background: #000;
}
</style>

View File

@ -1059,12 +1059,12 @@ const pointCode = ref()
if (a.deviceType == '00') {
if (a.alarmType == 'isc') {
try {
router.push({ path: '/index/hkplay', query: { pointId: a.pointId } })
// let routeData = router.resolve({ path: '/index/hkplay', query: { pointId: a.pointId } })
// router.push({ path: '/index/hkplay', query: { pointId: a.pointId } })
let routeData = router.resolve({ path: '/index/hkplay', query: { pointId: a.pointId } })
// console.log('🚀 ~ routeData:', JSON.stringify(routeData))
// window.location.href = routeData.href
// window.open(routeData.href, '_blank')
window.open(routeData.href, '_blank')
// window.open('http://172.10.10.161:9527/#/index/hkplay?pointId=43000000581314000013', '_blank') //token
// window.open('https://www.hndyjqrh.cn/#/index/hkplay?pointId=43000000581314000013', '_blank')
} catch (error) {