|
@@ -3,11 +3,28 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, reactive, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
|
|
|
|
|
|
+import { ref, reactive, onMounted, onBeforeUnmount, nextTick, watch } from 'vue'
|
|
|
|
|
+import { ptzdirection, ptzscale } from '@/api/pms/video/sipdevice'
|
|
|
|
|
|
|
|
// 响应式数据
|
|
// 响应式数据
|
|
|
const easyPlayerRef = ref(null)
|
|
const easyPlayerRef = ref(null)
|
|
|
-let playerInfo = ref(null)
|
|
|
|
|
|
|
+const playInfo = ref({})
|
|
|
|
|
+const playInfo2 = ref({})
|
|
|
|
|
+const playtype = ref('play')
|
|
|
|
|
+const props = defineProps({
|
|
|
|
|
+ playerInfo: {
|
|
|
|
|
+ type: Object,
|
|
|
|
|
+ default: null
|
|
|
|
|
+ },
|
|
|
|
|
+ width: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: '1000px'
|
|
|
|
|
+ },
|
|
|
|
|
+ height: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: '630px'
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
const videoUrl = ref('')
|
|
const videoUrl = ref('')
|
|
|
const isPlay = ref(false)
|
|
const isPlay = ref(false)
|
|
@@ -56,28 +73,28 @@ const onUse = (type) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const setFullscreen = () => {
|
|
const setFullscreen = () => {
|
|
|
- if (playerInfo.value) {
|
|
|
|
|
- playerInfo.value.setFullscreen(true)
|
|
|
|
|
|
|
+ if (playInfo.value) {
|
|
|
|
|
+ playInfo.value.setFullscreen(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const onPause = () => {
|
|
const onPause = () => {
|
|
|
- if (playerInfo.value) {
|
|
|
|
|
- playerInfo.value.pause()
|
|
|
|
|
|
|
+ if (playInfo.value) {
|
|
|
|
|
+ playInfo.value.pause()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const onMute = () => {
|
|
const onMute = () => {
|
|
|
- if (playerInfo.value) {
|
|
|
|
|
- playerInfo.value.setMute(true)
|
|
|
|
|
|
|
+ if (playInfo.value) {
|
|
|
|
|
+ playInfo.value.setMute(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const onPlayer = () => {
|
|
const onPlayer = () => {
|
|
|
isPlay.value = true
|
|
isPlay.value = true
|
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
|
- if (playerInfo.value) {
|
|
|
|
|
- playerInfo.value
|
|
|
|
|
|
|
+ if (playInfo.value) {
|
|
|
|
|
+ playInfo.value
|
|
|
.play(videoUrl.value)
|
|
.play(videoUrl.value)
|
|
|
.then(() => {})
|
|
.then(() => {})
|
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
@@ -92,8 +109,8 @@ const onPlayerPlayback = () => {
|
|
|
playCreate()
|
|
playCreate()
|
|
|
config.isLive = false
|
|
config.isLive = false
|
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
|
- if (playerInfo.value) {
|
|
|
|
|
- playerInfo.value
|
|
|
|
|
|
|
+ if (playInfo.value) {
|
|
|
|
|
+ playInfo.value
|
|
|
.play(videoUrl.value)
|
|
.play(videoUrl.value)
|
|
|
.then(() => {})
|
|
.then(() => {})
|
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
@@ -112,9 +129,9 @@ const onStop = async () => {
|
|
|
|
|
|
|
|
const onDestroy = () => {
|
|
const onDestroy = () => {
|
|
|
return new Promise((resolve) => {
|
|
return new Promise((resolve) => {
|
|
|
- if (playerInfo.value) {
|
|
|
|
|
- playerInfo.value.destroy()
|
|
|
|
|
- playerInfo.value = null
|
|
|
|
|
|
|
+ if (playInfo.value) {
|
|
|
|
|
+ playInfo.value.destroy()
|
|
|
|
|
+ playInfo.value = null
|
|
|
}
|
|
}
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
resolve()
|
|
resolve()
|
|
@@ -128,6 +145,33 @@ const onReplay = async () => {
|
|
|
onPlayer()
|
|
onPlayer()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 处理PTZ控制
|
|
|
|
|
+const handlePtz = (arrow) => {
|
|
|
|
|
+ let leftRight = 0
|
|
|
|
|
+ let upDown = 0
|
|
|
|
|
+ if (arrow === 'left') {
|
|
|
|
|
+ leftRight = 2
|
|
|
|
|
+ } else if (arrow === 'right') {
|
|
|
|
|
+ leftRight = 1
|
|
|
|
|
+ } else if (arrow === 'up') {
|
|
|
|
|
+ upDown = 1
|
|
|
|
|
+ } else if (arrow === 'down') {
|
|
|
|
|
+ upDown = 2
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ leftRight: leftRight,
|
|
|
|
|
+ upDown: upDown,
|
|
|
|
|
+ moveSpeed: 125
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (playInfo.value && playInfo.value.playtype !== '') {
|
|
|
|
|
+ ptzdirection(playInfo.value.deviceId, playInfo.value.channelId, data).then(async (response) => {
|
|
|
|
|
+ //console.log("云台方向控制:" + JSON.stringify(response))
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const playCreate = () => {
|
|
const playCreate = () => {
|
|
|
const container = easyPlayerRef.value
|
|
const container = easyPlayerRef.value
|
|
|
if (!container) return
|
|
if (!container) return
|
|
@@ -158,6 +202,10 @@ const playCreate = () => {
|
|
|
console.log('is fullscreen', flag)
|
|
console.log('is fullscreen', flag)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ easyplayer.on('ptz', (direction) => {
|
|
|
|
|
+ handlePtz(direction)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
easyplayer.on('playbackRate', (rate) => {
|
|
easyplayer.on('playbackRate', (rate) => {
|
|
|
easyplayer.setRate(rate)
|
|
easyplayer.setRate(rate)
|
|
|
})
|
|
})
|
|
@@ -166,11 +214,31 @@ const playCreate = () => {
|
|
|
console.log('playbackSeek', data)
|
|
console.log('playbackSeek', data)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- playerInfo.value = easyplayer
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ playInfo.value = easyplayer
|
|
|
|
|
+ if (playInfo2.value && playInfo2.value.channelId && playInfo2.value.deviceId) {
|
|
|
|
|
+ playInfo.value.channelId = playInfo2.value.channelId
|
|
|
|
|
+ playInfo.value.deviceId = playInfo2.value.deviceId
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ playInfo.value.playtype = playtype.value
|
|
|
|
|
+}
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.playerInfo,
|
|
|
|
|
+ (newVal, oldVal) => {
|
|
|
|
|
+ playInfo.value = newVal
|
|
|
|
|
+ playInfo2.value = newVal
|
|
|
|
|
+ if (newVal && newVal.playtype !== '') {
|
|
|
|
|
+ playtype.value = newVal.playtype
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+)
|
|
|
// 生命周期钩子
|
|
// 生命周期钩子
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
|
|
+ playInfo.value = props.playerInfo
|
|
|
|
|
+ playInfo2.value = props.playerInfo
|
|
|
|
|
+ if (playInfo.value && playInfo.value.playtype !== '') {
|
|
|
|
|
+ playtype.value = playInfo.value.playtype
|
|
|
|
|
+ }
|
|
|
playCreate()
|
|
playCreate()
|
|
|
})
|
|
})
|
|
|
|
|
|