Skip to content

Commit c2af664

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

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SPDX-FileCopyrightText = "2024 Nextcloud GmbH and Nextcloud contributors"
3636
SPDX-License-Identifier = "AGPL-3.0-or-later"
3737

3838
[[annotations]]
39-
path = ["img/Nextcloud.mp4", "img/Nextcloud.webm", "img/nextcloudLogo.svg"]
39+
path = ["img/Nextcloud.mp4", "img/Nextcloud.webm", "img/Nextcloud.webp", "img/nextcloudLogo.svg"]
4040
precedence = "aggregate"
4141
SPDX-FileCopyrightText = "2019 Nextcloud GmbH"
4242
SPDX-License-Identifier = "LicenseRef-NextcloudTrademarks"

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)