-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
RecordingControls.vue
65 lines (59 loc) · 1.6 KB
/
RecordingControls.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script setup lang="ts">
import { useLocalStorage } from '@vueuse/core'
import { onMounted, watch } from 'vue'
import { recorder } from '../logic/recording'
import { currentCamera, showRecordingDialog } from '../state'
import DevicesList from './DevicesList.vue'
import MenuButton from './MenuButton.vue'
import IconButton from './IconButton.vue'
const {
recording,
showAvatar,
streamCamera,
stopRecording,
toggleAvatar,
} = recorder
const previousAvatar = useLocalStorage('slidev-webcam-show', false)
watch(showAvatar, () => {
previousAvatar.value = showAvatar.value
})
function toggleRecording() {
if (recording.value)
stopRecording()
else
showRecordingDialog.value = true
}
onMounted(() => {
if (previousAvatar.value && !showAvatar.value)
toggleAvatar()
})
</script>
<template>
<IconButton
v-if="currentCamera !== 'none'"
class="<md:hidden"
:class="{ 'text-green-500': Boolean(showAvatar && streamCamera) }"
title="Toggle camera view"
@click="toggleAvatar"
>
<carbon:user-avatar />
</IconButton>
<IconButton
:class="{ 'text-red-500': recording }"
:title="recording ? 'Stop record video' : 'Record video'"
@click="toggleRecording"
>
<carbon:stop-outline v-if="recording" />
<carbon:video v-else />
</IconButton>
<MenuButton :disabled="recording">
<template #button>
<IconButton title="Select recording device" class="h-full !text-sm !px-0 aspect-initial">
<carbon:chevron-up class="opacity-50" />
</IconButton>
</template>
<template #menu>
<DevicesList />
</template>
</MenuButton>
</template>