|
|
@ -199,6 +199,7 @@ export default { |
|
|
streamCleanupPromise: null, |
|
|
streamCleanupPromise: null, |
|
|
selectedCode: '', |
|
|
selectedCode: '', |
|
|
layout: 9, |
|
|
layout: 9, |
|
|
|
|
|
fullscreenIndex: -1, |
|
|
layouts: [ |
|
|
layouts: [ |
|
|
{ value: 1, label: '单画面' }, { value: 4, label: '四画面' }, |
|
|
{ value: 1, label: '单画面' }, { value: 4, label: '四画面' }, |
|
|
{ value: 9, label: '九画面' }, { value: 16, label: '十六画面' } |
|
|
{ value: 9, label: '九画面' }, { value: 16, label: '十六画面' } |
|
|
@ -259,6 +260,8 @@ export default { |
|
|
visibleSlots() { return this.slots.slice(0, this.capacity) }, |
|
|
visibleSlots() { return this.slots.slice(0, this.capacity) }, |
|
|
activeSlot() { return this.slots[this.activeIndex] || null }, |
|
|
activeSlot() { return this.slots[this.activeIndex] || null }, |
|
|
activeMuted() { return this.controlTarget ? this.controlTarget.muted !== false : true }, |
|
|
activeMuted() { return this.controlTarget ? this.controlTarget.muted !== false : true }, |
|
|
|
|
|
// 单画面用主码流,4/9/16 宫格用辅码流,减轻多路视频卡顿 |
|
|
|
|
|
streamType() { return this.layout === 1 ? 1 : 2 }, |
|
|
gridStyle() { |
|
|
gridStyle() { |
|
|
const columns = { 1: 1, 4: 2, 9: 3, 16: 4 }[this.layout] |
|
|
const columns = { 1: 1, 4: 2, 9: 3, 16: 4 }[this.layout] |
|
|
return { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, gridTemplateRows: `repeat(${columns}, minmax(0, 1fr))` } |
|
|
return { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, gridTemplateRows: `repeat(${columns}, minmax(0, 1fr))` } |
|
|
@ -269,6 +272,7 @@ export default { |
|
|
created() { |
|
|
created() { |
|
|
this.$root.$on('video-layout-change', this.changeLayout) |
|
|
this.$root.$on('video-layout-change', this.changeLayout) |
|
|
this.$root.$on('video-control-panel-change', this.changeControlPanel) |
|
|
this.$root.$on('video-control-panel-change', this.changeControlPanel) |
|
|
|
|
|
document.addEventListener('fullscreenchange', this.handleFullscreenChange) |
|
|
this.$root.$emit('video-layout-updated', this.layout) |
|
|
this.$root.$emit('video-layout-updated', this.layout) |
|
|
this.$root.$emit('video-control-panel-updated', this.controlPanelExpanded) |
|
|
this.$root.$emit('video-control-panel-updated', this.controlPanelExpanded) |
|
|
this.loadConfig() |
|
|
this.loadConfig() |
|
|
@ -293,6 +297,7 @@ export default { |
|
|
this.stopTreeResize() |
|
|
this.stopTreeResize() |
|
|
this.lifecycleId += 1 |
|
|
this.lifecycleId += 1 |
|
|
this.pageActive = false |
|
|
this.pageActive = false |
|
|
|
|
|
document.removeEventListener('fullscreenchange', this.handleFullscreenChange) |
|
|
this.$root.$off('video-layout-change', this.changeLayout) |
|
|
this.$root.$off('video-layout-change', this.changeLayout) |
|
|
this.$root.$off('video-control-panel-change', this.changeControlPanel) |
|
|
this.$root.$off('video-control-panel-change', this.changeControlPanel) |
|
|
this.closeAll() |
|
|
this.closeAll() |
|
|
@ -421,11 +426,11 @@ export default { |
|
|
this.selectChannel(channel) |
|
|
this.selectChannel(channel) |
|
|
this.startChannel(channel) |
|
|
this.startChannel(channel) |
|
|
}, |
|
|
}, |
|
|
async startChannel(channel, targetIndex = this.activeIndex, attemptedCameraCodes = []) { |
|
|
|
|
|
|
|
|
async startChannel(channel, targetIndex = this.activeIndex, attemptedCameraCodes = [], streamType = this.streamType) { |
|
|
if (!this.pageActive || !channel || !channel.cameraCode) return |
|
|
if (!this.pageActive || !channel || !channel.cameraCode) return |
|
|
const index = targetIndex |
|
|
const index = targetIndex |
|
|
const current = this.slots[index] |
|
|
const current = this.slots[index] |
|
|
if (current && current.cameraCode === channel.cameraCode) { |
|
|
|
|
|
|
|
|
if (current && current.cameraCode === channel.cameraCode && current.streamType === streamType) { |
|
|
this.controlTarget = current |
|
|
this.controlTarget = current |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
@ -439,7 +444,8 @@ export default { |
|
|
muted: true, |
|
|
muted: true, |
|
|
errorNotified: false, |
|
|
errorNotified: false, |
|
|
attemptedCameraCodes: [...attemptedCameraCodes, channel.cameraCode], |
|
|
attemptedCameraCodes: [...attemptedCameraCodes, channel.cameraCode], |
|
|
timer: null |
|
|
|
|
|
|
|
|
timer: null, |
|
|
|
|
|
streamType |
|
|
} |
|
|
} |
|
|
this.$set(this.slots, index, slot) |
|
|
this.$set(this.slots, index, slot) |
|
|
if (index === this.activeIndex) { |
|
|
if (index === this.activeIndex) { |
|
|
@ -449,7 +455,7 @@ export default { |
|
|
this.presets = [] |
|
|
this.presets = [] |
|
|
this.presetId = null |
|
|
this.presetId = null |
|
|
try { |
|
|
try { |
|
|
slot.startPromise = startLive(channel) |
|
|
|
|
|
|
|
|
slot.startPromise = startLive(channel, streamType) |
|
|
const result = await slot.startPromise |
|
|
const result = await slot.startPromise |
|
|
if (this.slots[index] !== slot) return |
|
|
if (this.slots[index] !== slot) return |
|
|
this.applyLiveResult(index, slot, result) |
|
|
this.applyLiveResult(index, slot, result) |
|
|
@ -587,6 +593,29 @@ export default { |
|
|
const card = this.$refs.cameraCards && this.$refs.cameraCards[index] |
|
|
const card = this.$refs.cameraCards && this.$refs.cameraCards[index] |
|
|
if (card && card.requestFullscreen) card.requestFullscreen() |
|
|
if (card && card.requestFullscreen) card.requestFullscreen() |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 放大(全屏)观看时切主码流,退出全屏后恢复当前布局对应的码流 |
|
|
|
|
|
async handleFullscreenChange() { |
|
|
|
|
|
const fsElement = document.fullscreenElement |
|
|
|
|
|
if (fsElement) { |
|
|
|
|
|
const cards = this.$refs.cameraCards || [] |
|
|
|
|
|
const index = cards.indexOf(fsElement) |
|
|
|
|
|
if (index >= 0) { |
|
|
|
|
|
this.fullscreenIndex = index |
|
|
|
|
|
await this.switchSlotStream(index, 1) |
|
|
|
|
|
} |
|
|
|
|
|
} else if (this.fullscreenIndex >= 0) { |
|
|
|
|
|
const index = this.fullscreenIndex |
|
|
|
|
|
this.fullscreenIndex = -1 |
|
|
|
|
|
await this.switchSlotStream(index, this.streamType) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
async switchSlotStream(index, streamType) { |
|
|
|
|
|
const slot = this.slots[index] |
|
|
|
|
|
if (!this.pageActive || !slot || slot.streamType === streamType) return |
|
|
|
|
|
await this.closeSlot(index, false) |
|
|
|
|
|
if (!this.pageActive) return |
|
|
|
|
|
await this.startChannel(slot, index, [], streamType) |
|
|
|
|
|
}, |
|
|
openPlayback(slot) { |
|
|
openPlayback(slot) { |
|
|
this.$router.push({ name: 'VideoHistoryPlayback', query: { cameraCode: slot.cameraCode }}) |
|
|
this.$router.push({ name: 'VideoHistoryPlayback', query: { cameraCode: slot.cameraCode }}) |
|
|
}, |
|
|
}, |
|
|
|