Skip to content

Commit c8480b2

Browse files
committed
fix: gracefully handle disabled autoplay policies
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 0733318 commit c8480b2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

img/Nextcloud.webp

67.2 KB
Loading

src/components/pages/IntroAnimation.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<template>
77
<div :class="$style.wrapper">
88
<video
9+
ref="video"
910
:class="$style.video"
1011
playsinline
1112
autoplay
@@ -21,16 +22,27 @@
2122
<script setup lang="ts">
2223
import { translate as t } from '@nextcloud/l10n'
2324
import { imagePath } from '@nextcloud/router'
25+
import { onMounted, useTemplateRef } from 'vue'
2426
2527
const emit = defineEmits<{
2628
(e: 'next'): void
2729
}>()
2830
2931
const videoMp4 = imagePath('firstrunwizard', 'Nextcloud.mp4')
3032
const videoWebm = imagePath('firstrunwizard', 'Nextcloud.webm')
31-
33+
const videoFallbackImage = imagePath('firstrunwizard', 'Nextcloud.webp')
3234
const videoFallbackText = t('firstrunwizard', 'Welcome to {cloudName}!', { cloudName: window.OC.theme.name })
3335
36+
const videoElement = useTemplateRef('video')
37+
38+
onMounted(() => {
39+
// check if the browser allows auto play - otherwise we need to skip this
40+
if (navigator.getAutoplayPolicy && navigator.getAutoplayPolicy(videoElement.value) === 'disallowed') {
41+
videoElement.value!.poster = videoFallbackImage
42+
window.setTimeout(handleEnded, 2500)
43+
}
44+
})
45+
3446
/**
3547
* Handle video has ended
3648
*/

0 commit comments

Comments
 (0)