feat: added autoplay setting (#1303)

closes https://github.com/elk-zone/elk/issues/1235
This commit is contained in:
Niklas Wolf 2023-01-19 19:33:50 +01:00 committed by GitHub
parent 33b5947170
commit 126619be92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 1 deletions

View file

@ -65,9 +65,11 @@ const video = ref<HTMLVideoElement | undefined>()
const prefersReducedMotion = usePreferredReducedMotion()
const isAudio = $computed(() => attachment.type === 'audio')
const enableAutoplay = usePreferences('enableAutoplay')
useIntersectionObserver(video, (entries) => {
const ready = video.value?.dataset.ready === 'true'
if (prefersReducedMotion.value === 'reduce') {
if (prefersReducedMotion.value === 'reduce' || !enableAutoplay.value) {
if (ready && !video.value?.paused)
video.value?.pause()