Commit ae0ed049e3abf244e806c26ff1f0a8ff9a023c61

Authored by xp.Huang
2 parents f19ce09d bcb4888d

Merge branch 'dev_local_latest' into 'main_dev'

perf(src/packages/external/Informations): 修改多个摄像头,自动开启切换

See merge request yunteng/thingskit-view!213
... ... @@ -56,8 +56,8 @@ export interface videoList {
56 56 }
57 57
58 58 export const option = {
59   - autoSwitch: false, //开启切换
60   - interval: 2000, // 自动播放的间隔(ms)
  59 + autoSwitch: true, //开启切换
  60 + interval: 3000, // 自动播放的间隔(ms)
61 61 dataset: [
62 62 {
63 63 id: null,
... ...
... ... @@ -57,6 +57,7 @@ export interface Dataset {
57 57
58 58 export const option = {
59 59 dataset: {} as Dataset,
  60 + customVideoUrl: '', //用于手动输入视频流地址
60 61 autoplay: true,
61 62 poster: '',
62 63 sourceType: sourceTypeEnum.CUSTOM,
... ...
... ... @@ -19,7 +19,7 @@
19 19 <setting-item-box v-if="optionData.sourceType === sourceTypeEnum.CUSTOM" name="源地址" :alone="true">
20 20 <setting-item>
21 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 23 </n-input-group>
24 24 </setting-item>
25 25 </setting-item-box>
... ... @@ -59,9 +59,8 @@ import { PropType, ref, onMounted } from 'vue'
59 59 import { AccessMode, option, sourceTypeEnum, videoListInterface, sourceTypeNameEnum, Dataset } from './config'
60 60 import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
61 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 63 import { TKUpload } from '@/components/external/Common/TKUpload'
64   -import { getVideoControlStart } from '@/api/external/flvPlay'
65 64
66 65 const props = defineProps({
67 66 optionData: {
... ... @@ -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 113 const handleChecked = (value: string) => {
134 114 props.optionData.dataset = {} as Dataset
135 115 props.optionData.organization = ''
136 116 props.optionData.videoId = null
  117 + props.optionData.customVideoUrl = ''
137 118 if (value === sourceTypeEnum.PLATFORM) {
138 119 getOriginationList()
139 120 }
... ... @@ -151,14 +132,6 @@ const handleSelect = (_: string, e: videoListInterface) => {
151 132 deviceId,
152 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 137 onMounted(() => {
... ...
... ... @@ -12,7 +12,7 @@
12 12 <script setup lang="ts">
13 13 import { PropType, toRefs, shallowReactive, watch, ref } from 'vue'
14 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 16 import { VideoPlay } from './components'
17 17 import { getVideoControlStart } from '@/api/external/flvPlay'
18 18 import { getVideoUrl } from '@/api/external/common'
... ... @@ -28,7 +28,7 @@ const showLoading = ref(false)
28 28
29 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 33 const option = shallowReactive({
34 34 dataset: configOption.dataset,
... ... @@ -94,6 +94,20 @@ watch(
94 94 )
95 95
96 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 111 () => [poster.value, autoplay.value],
98 112 newData => {
99 113 option.poster = newData.at(-2) as string
... ...