@@ -116,12 +116,18 @@ const setVideoSources = async () => Promise.allSettled(sources.value.map(async (
116116 videoElements[source .id ].srcObject = await getStreamForMediaSource (source .id )
117117}))
118118
119- onMounted (async () => {
120- await requestDesktopCapturerSources ()
119+ const previewType = ref (' none' )
120+
121+ const showLivePreviews = async () => {
122+ previewType .value = ' video'
121123 // Wait for video elements to be mounted
122124 await nextTick ()
123125 // Set streams for all ids
124126 await setVideoSources ()
127+ }
128+
129+ onMounted (async () => {
130+ await requestDesktopCapturerSources ()
125131})
126132
127133onBeforeUnmount (() => {
@@ -143,16 +149,33 @@ onBeforeUnmount(() => {
143149 size= " normal"
144150 : buttons= " dialogButtons"
145151 @update: open= " handleCancel" >
146- < div v- if = " sources" class = " capture-source-grid" >
152+ < template v- if = " sources" >
153+ < div> sources: {{ sources .map ((source ) => source .id ) }}< / div>
154+ < div>
155+ < button : disabled= " previewType === 'video'" @click= " showLivePreviews" >
156+ Show live previews
157+ < / button>
158+ < button : disabled= " previewType === 'thumbnail'" @click= " previewType = 'thumbnail'" >
159+ Show thumbnails
160+ < / button>
161+ < / div>
162+ < / template>
163+ < div v- if = " sources && previewType !== 'none'" class = " capture-source-grid" >
147164 < label v- for = " source in sources" : key= " source.id" class = " capture-source" >
148165 < input : id= " source.id"
149166 v- model= " selectedSourceId"
150167 class = " capture-source__input"
151168 type= " radio"
152169 : value= " source.id" >
153- < video : ref= " (element) => videoElements[source.id] = element"
170+ < video v- if = " previewType === 'video'"
171+ : ref= " (element) => videoElements[source.id] = element"
154172 class = " capture-source__preview"
155173 @loadedmetadata= " $event.target.play()" / >
174+ < img v- else - if = " previewType === 'thumbnail'"
175+ alt= " "
176+ : src= " source.thumbnail"
177+ class = " capture-source__preview" >
178+ < div v- else class = " capture-source__preview" > Preview is no available< / div>
156179 < span class = " capture-source__caption" >
157180 < img v- if = " source.icon"
158181 alt= " "
@@ -164,7 +187,7 @@ onBeforeUnmount(() => {
164187 < / span>
165188 < / label>
166189 < / div>
167- < NcEmptyContent v- else : name= " t('talk_desktop', 'Loading …')" >
190+ < NcEmptyContent v- else : name= " sources ? 'Please, press a button' : t('talk_desktop', 'Loading …')" >
168191 < template #icon>
169192 < NcLoadingIcon / >
170193 < / template>
0 commit comments