Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video: add state variable & visual feedback to monitor video processing #821

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/components/mini-widgets/MiniVideoRecorder.vue
Expand Up @@ -4,10 +4,17 @@
class="flex justify-around px-2 py-1 text-center rounded-lg h-9 w-28 align-center bg-slate-800/60"
>
<div
:class="{ 'blob red w-5 opacity-100 rounded-sm': isRecording, 'opacity-30': isOutside && !isRecording }"
v-if="!isProcessingVideo"
:class="{
'blob red w-5 opacity-100 rounded-sm': isRecording,
'opacity-30 bg-red-400': isOutside && !isRecording,
}"
class="w-6 transition-all duration-500 rounded-full aspect-square bg-red-lighten-1 hover:cursor-pointer opacity-70 hover:opacity-90"
@click="toggleRecording()"
/>
<div v-else>
<v-icon class="w-6 h-6 animate-spin" color="white">mdi-loading</v-icon>
</div>
<template v-if="!isRecording">
<div
v-if="nameSelectedStream"
Expand All @@ -18,9 +25,12 @@
</div>
<FontAwesomeIcon v-else icon="fa-solid fa-video" class="h-6 text-slate-100" />
</template>
<div v-else class="w-16 text-justify text-slate-100">
<div v-if="isRecording && !isProcessingVideo" class="w-16 text-justify text-slate-100">
{{ timePassedString }}
</div>
<div v-else-if="isProcessingVideo" class="w-16 text-justify text-slate-100">
<div class="text-center text-xs text-white select-none flex-nowrap">Processing video...</div>
</div>
</div>
<v-dialog v-model="isStreamSelectDialogOpen" width="auto">
<div class="p-6 m-5 bg-white rounded-md">
Expand Down Expand Up @@ -90,6 +100,7 @@ const isStreamSelectDialogOpen = ref(false)
const isLoadingStream = ref(false)
const timeNow = useTimestamp({ interval: 100 })
const mediaStream = ref<MediaStream | undefined>()
const isProcessingVideo = ref(false)

onBeforeMount(async () => {
// Set initial widget options if they don't exist
Expand Down Expand Up @@ -128,6 +139,7 @@ const toggleRecording = async (): Promise<void> => {
if (isRecording.value) {
if (nameSelectedStream.value !== undefined) {
videoStore.stopRecording(nameSelectedStream.value)
isProcessingVideo.value = true
}
return
}
Expand Down Expand Up @@ -215,6 +227,14 @@ if (widgetStore.isRealMiniWidget(miniWidget.value)) {
}
onBeforeUnmount(() => clearInterval(streamConnectionRoutine))

// Check if there are videos being processed
watch(
() => videoStore.areThereVideosProcessing,
(newValue) => {
isProcessingVideo.value = newValue
}
)

// Try to prevent user from closing Cockpit when a stream is being recorded
watch(isRecording, () => {
if (!isRecording.value) {
Expand Down