fix: autoplay vidéos mobile + remplacement background image
All checks were successful
Deploy / Deploy to Production (push) Successful in 21s
All checks were successful
Deploy / Deploy to Production (push) Successful in 21s
- Home : matchMedia pour ne jouer que la vidéo visible (desktop/mobile) - Expertise : play-then-pause pour forcer le décodage frame 0 - App : remplacement image de fond scrollable-page Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e6062ba2e7
commit
2bd531f7b2
4 changed files with 25 additions and 5 deletions
|
Before Width: | Height: | Size: 4.1 MiB After Width: | Height: | Size: 4.1 MiB |
|
|
@ -164,7 +164,7 @@
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
background-image: url('/assets/img/BACKGROUND2.52010fb6a490a17ef475.png');
|
background-image: url('/assets/img/scrollable-page-background.png');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,11 @@
|
||||||
isReverse = false
|
isReverse = false
|
||||||
if (videoRev) videoRev.currentTime = dur
|
if (videoRev) videoRev.currentTime = dur
|
||||||
requestAnimationFrame(() => computeOffset())
|
requestAnimationFrame(() => computeOffset())
|
||||||
|
// Force le décodage de la première frame (nécessaire sur mobile)
|
||||||
|
videoFwd.play().then(() => {
|
||||||
|
videoFwd.pause()
|
||||||
|
videoFwd.currentTime = 0
|
||||||
|
}).catch(() => {})
|
||||||
}
|
}
|
||||||
if (videoFwd?.duration) {
|
if (videoFwd?.duration) {
|
||||||
init()
|
init()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@
|
||||||
|
|
||||||
const currentLang = $derived(locale.current)
|
const currentLang = $derived(locale.current)
|
||||||
|
|
||||||
|
let videoDesktop = $state(null)
|
||||||
|
let videoMobile = $state(null)
|
||||||
|
|
||||||
function playWhenReady(video) {
|
function playWhenReady(video) {
|
||||||
if (!video) return
|
if (!video) return
|
||||||
|
|
||||||
|
|
@ -33,8 +36,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
playWhenReady(document.getElementById('home-video'))
|
const mql = window.matchMedia('(max-width: 1000px)')
|
||||||
playWhenReady(document.getElementById('home-video-mobile'))
|
|
||||||
|
function syncVideo(isMobile) {
|
||||||
|
const active = isMobile ? videoMobile : videoDesktop
|
||||||
|
const inactive = isMobile ? videoDesktop : videoMobile
|
||||||
|
if (inactive) inactive.pause()
|
||||||
|
playWhenReady(active)
|
||||||
|
}
|
||||||
|
|
||||||
|
syncVideo(mql.matches)
|
||||||
|
const onChange = (e) => syncVideo(e.matches)
|
||||||
|
mql.addEventListener('change', onChange)
|
||||||
|
|
||||||
|
return () => mql.removeEventListener('change', onChange)
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleExplore() {
|
function handleExplore() {
|
||||||
|
|
@ -46,24 +61,24 @@
|
||||||
<div class="home-bg">
|
<div class="home-bg">
|
||||||
<figure class="home-figure">
|
<figure class="home-figure">
|
||||||
<video
|
<video
|
||||||
|
bind:this={videoDesktop}
|
||||||
muted
|
muted
|
||||||
playsinline
|
playsinline
|
||||||
loop
|
loop
|
||||||
preload="auto"
|
preload="auto"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
id="home-video"
|
|
||||||
class="home-video home-video-desktop"
|
class="home-video home-video-desktop"
|
||||||
poster={data.backgroundVideoPoster ?? undefined}
|
poster={data.backgroundVideoPoster ?? undefined}
|
||||||
>
|
>
|
||||||
<source src={data.backgroundVideo ?? '/assets/video/Website_version.mp4'} type="video/mp4" />
|
<source src={data.backgroundVideo ?? '/assets/video/Website_version.mp4'} type="video/mp4" />
|
||||||
</video>
|
</video>
|
||||||
<video
|
<video
|
||||||
|
bind:this={videoMobile}
|
||||||
muted
|
muted
|
||||||
playsinline
|
playsinline
|
||||||
loop
|
loop
|
||||||
preload="auto"
|
preload="auto"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
id="home-video-mobile"
|
|
||||||
class="home-video home-video-mobile"
|
class="home-video home-video-mobile"
|
||||||
poster={data.backgroundVideoMobilePoster ?? undefined}
|
poster={data.backgroundVideoMobilePoster ?? undefined}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue