Commit bcb4888d8451bf867f010cce7246d19a1437a33a
Committed by
xp.Huang
1 parent
f19ce09d
perf(src/packages/external/Informations): 修改多个摄像头,自动开启切换
Showing
4 changed files
with
22 additions
and
34 deletions
| @@ -56,8 +56,8 @@ export interface videoList { | @@ -56,8 +56,8 @@ export interface videoList { | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | export const option = { | 58 | export const option = { |
| 59 | - autoSwitch: false, //开启切换 | ||
| 60 | - interval: 2000, // 自动播放的间隔(ms) | 59 | + autoSwitch: true, //开启切换 |
| 60 | + interval: 3000, // 自动播放的间隔(ms) | ||
| 61 | dataset: [ | 61 | dataset: [ |
| 62 | { | 62 | { |
| 63 | id: null, | 63 | id: null, |
| @@ -57,6 +57,7 @@ export interface Dataset { | @@ -57,6 +57,7 @@ export interface Dataset { | ||
| 57 | 57 | ||
| 58 | export const option = { | 58 | export const option = { |
| 59 | dataset: {} as Dataset, | 59 | dataset: {} as Dataset, |
| 60 | + customVideoUrl: '', //用于手动输入视频流地址 | ||
| 60 | autoplay: true, | 61 | autoplay: true, |
| 61 | poster: '', | 62 | poster: '', |
| 62 | sourceType: sourceTypeEnum.CUSTOM, | 63 | sourceType: sourceTypeEnum.CUSTOM, |
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | <setting-item-box v-if="optionData.sourceType === sourceTypeEnum.CUSTOM" name="源地址" :alone="true"> | 19 | <setting-item-box v-if="optionData.sourceType === sourceTypeEnum.CUSTOM" name="源地址" :alone="true"> |
| 20 | <setting-item> | 20 | <setting-item> |
| 21 | <n-input-group> | 21 | <n-input-group> |
| 22 | - <n-input v-model:value="optionData.dataset" size="small" placeholder="请输入源地址"></n-input> | 22 | + <n-input v-model:value="optionData.customVideoUrl" size="small" placeholder="请输入源地址"></n-input> |
| 23 | </n-input-group> | 23 | </n-input-group> |
| 24 | </setting-item> | 24 | </setting-item> |
| 25 | </setting-item-box> | 25 | </setting-item-box> |
| @@ -59,9 +59,8 @@ import { PropType, ref, onMounted } from 'vue' | @@ -59,9 +59,8 @@ import { PropType, ref, onMounted } from 'vue' | ||
| 59 | import { AccessMode, option, sourceTypeEnum, videoListInterface, sourceTypeNameEnum, Dataset } from './config' | 59 | import { AccessMode, option, sourceTypeEnum, videoListInterface, sourceTypeNameEnum, Dataset } from './config' |
| 60 | import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | 60 | import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' |
| 61 | import { NTreeSelect } from 'naive-ui' | 61 | import { NTreeSelect } from 'naive-ui' |
| 62 | -import { getOrganizationList, getVideoList, getVideoUrl } from '@/api/external/common/index' | 62 | +import { getOrganizationList, getVideoList } from '@/api/external/common/index' |
| 63 | import { TKUpload } from '@/components/external/Common/TKUpload' | 63 | import { TKUpload } from '@/components/external/Common/TKUpload' |
| 64 | -import { getVideoControlStart } from '@/api/external/flvPlay' | ||
| 65 | 64 | ||
| 66 | const props = defineProps({ | 65 | const props = defineProps({ |
| 67 | optionData: { | 66 | optionData: { |
| @@ -111,29 +110,11 @@ const getVideoLists = async (organizationId: string) => { | @@ -111,29 +110,11 @@ const getVideoLists = async (organizationId: string) => { | ||
| 111 | }) | 110 | }) |
| 112 | } | 111 | } |
| 113 | 112 | ||
| 114 | -//针对萤石云或者海康威视,根据视频id获取播放流地址 | ||
| 115 | -const getVideoUrlById = async (id: string) => { | ||
| 116 | - const res = await getVideoUrl(id) | ||
| 117 | - if (!res) return | ||
| 118 | - const { url } = res.data | ||
| 119 | - props.optionData.dataset = url | ||
| 120 | -} | ||
| 121 | - | ||
| 122 | -//针对gbt28181,根据设备id和通道号获取播放流地址 | ||
| 123 | -const getVideoControlList = async (deviceId: string, channelId: string) => { | ||
| 124 | - const { | ||
| 125 | - data: { flv } | ||
| 126 | - } = await getVideoControlStart({ | ||
| 127 | - deviceId, | ||
| 128 | - channelId | ||
| 129 | - }) | ||
| 130 | - props.optionData.dataset = flv | ||
| 131 | -} | ||
| 132 | - | ||
| 133 | const handleChecked = (value: string) => { | 113 | const handleChecked = (value: string) => { |
| 134 | props.optionData.dataset = {} as Dataset | 114 | props.optionData.dataset = {} as Dataset |
| 135 | props.optionData.organization = '' | 115 | props.optionData.organization = '' |
| 136 | props.optionData.videoId = null | 116 | props.optionData.videoId = null |
| 117 | + props.optionData.customVideoUrl = '' | ||
| 137 | if (value === sourceTypeEnum.PLATFORM) { | 118 | if (value === sourceTypeEnum.PLATFORM) { |
| 138 | getOriginationList() | 119 | getOriginationList() |
| 139 | } | 120 | } |
| @@ -151,14 +132,6 @@ const handleSelect = (_: string, e: videoListInterface) => { | @@ -151,14 +132,6 @@ const handleSelect = (_: string, e: videoListInterface) => { | ||
| 151 | deviceId, | 132 | deviceId, |
| 152 | value | 133 | value |
| 153 | } | 134 | } |
| 154 | - | ||
| 155 | - // if (accessMode === AccessMode.Streaming) { | ||
| 156 | - // getVideoUrlById(id) | ||
| 157 | - // } else if (accessMode === AccessMode.GBT28181) { | ||
| 158 | - // getVideoControlList(deviceId, channelId) | ||
| 159 | - // } else { | ||
| 160 | - // getCustomUrl(customUrl) | ||
| 161 | - // } | ||
| 162 | } | 135 | } |
| 163 | 136 | ||
| 164 | onMounted(() => { | 137 | onMounted(() => { |
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | <script setup lang="ts"> | 12 | <script setup lang="ts"> |
| 13 | import { PropType, toRefs, shallowReactive, watch, ref } from 'vue' | 13 | import { PropType, toRefs, shallowReactive, watch, ref } from 'vue' |
| 14 | import { CreateComponentType } from '@/packages/index.d' | 14 | import { CreateComponentType } from '@/packages/index.d' |
| 15 | -import { AccessMode, Dataset, option as configOption } from './config' | 15 | +import { AccessMode, Dataset, option as configOption, sourceTypeEnum } from './config' |
| 16 | import { VideoPlay } from './components' | 16 | import { VideoPlay } from './components' |
| 17 | import { getVideoControlStart } from '@/api/external/flvPlay' | 17 | import { getVideoControlStart } from '@/api/external/flvPlay' |
| 18 | import { getVideoUrl } from '@/api/external/common' | 18 | import { getVideoUrl } from '@/api/external/common' |
| @@ -28,7 +28,7 @@ const showLoading = ref(false) | @@ -28,7 +28,7 @@ const showLoading = ref(false) | ||
| 28 | 28 | ||
| 29 | const { w, h } = toRefs(props.chartConfig.attr) | 29 | const { w, h } = toRefs(props.chartConfig.attr) |
| 30 | 30 | ||
| 31 | -const { autoplay, dataset, poster } = toRefs(props.chartConfig.option as typeof configOption) | 31 | +const { autoplay, dataset, poster, customVideoUrl } = toRefs(props.chartConfig.option as typeof configOption) |
| 32 | 32 | ||
| 33 | const option = shallowReactive({ | 33 | const option = shallowReactive({ |
| 34 | dataset: configOption.dataset, | 34 | dataset: configOption.dataset, |
| @@ -94,6 +94,20 @@ watch( | @@ -94,6 +94,20 @@ watch( | ||
| 94 | ) | 94 | ) |
| 95 | 95 | ||
| 96 | watch( | 96 | watch( |
| 97 | + () => customVideoUrl.value, | ||
| 98 | + (newData) => { | ||
| 99 | + if(newData){ | ||
| 100 | + videoPlayerRef.value?.dispose() | ||
| 101 | + sourceUrl.value = newData; | ||
| 102 | + videoPlayerRef.value?.anewInit() | ||
| 103 | + } | ||
| 104 | + }, | ||
| 105 | + { | ||
| 106 | + immediate: true | ||
| 107 | + } | ||
| 108 | +) | ||
| 109 | + | ||
| 110 | +watch( | ||
| 97 | () => [poster.value, autoplay.value], | 111 | () => [poster.value, autoplay.value], |
| 98 | newData => { | 112 | newData => { |
| 99 | option.poster = newData.at(-2) as string | 113 | option.poster = newData.at(-2) as string |