-
Describe your problem 🧐Hi. When switching between pages the What is your question? 🙋♀️Is there a workaround for this? I've tried using URL to reduced test case 🔗Checked all these? 📚
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 8 replies
-
Hi @adamo , your problem is very likely not related to swup. A thing that always makes sense in these cases is to try to get it to work without swup first. In your case, you could try to add the <video autoplay muted loop playsinline poster="https://cedo.depcore.agency/themes/cedo//assets/images/FFFFFF-0.png">
<source src="https://cedo.depcore.agency/themes/cedo//assets/videos/1.mp4" type="video/mp4">
</video> |
Beta Was this translation helpful? Give feedback.
-
Does it also fail to load on initial load or only after page transitions triggered by swup? |
Beta Was this translation helpful? Give feedback.
-
Safari has a history of blocking autoplaying video quite aggressively. Blame it on the advertising industry ;) From the docs:
Following this, I'd try three things.
/** runs each time swup has fully rendered and faded in a page */
swup.hooks.on('visit:end', () => {
document.querySelectorAll('video[autoplay]').forEach(el => el.play());
});
Safari on iOS has been changing their handling of videos quite a few times, so don't expect this to continue to work next year, should you get it to work now... |
Beta Was this translation helpful? Give feedback.
-
@adamo I went ahead and created a reduced test case using your video. Turns out it had something to do with your video file. Using your original file, autoplay didn't work for me after a swup page visit, either (click on "Next Page", click on "Back"). I used handbrake to convert the file:
This is the converted video file: https://swup-demo-video-autoplay--hirasso.repl.co/video-1-handbrake.mp4 After I switched out the newly encoded video, it's now working for me. I'm afraid I don't know what exactly fixed it, but it definitely has something to do with a combination of these:
Reduced test cases really are the gold standard for debugging issues like these. We'll need to advertise them more in the future. |
Beta Was this translation helpful? Give feedback.
-
Side note: chrome on iOS is also just safari due to bad behaviour by Apple |
Beta Was this translation helpful? Give feedback.
-
One thing to double-check is that the device in questions isn't in power-saving mode when testing this behavior. I ran into this once and it took me a few hours to figure out why it wouldn't work on the unplugged MacBook but worked fine on the stationary iMac. |
Beta Was this translation helpful? Give feedback.
-
I had the same issue on mobile (tested with iOS), but also on computer (Mac). In my case, the issue didn't occur with Swup v3, it only happened with Swup v4. |
Beta Was this translation helpful? Give feedback.
That didn't work for me so I've finally ended up doing what the scripts plugin does but for video and hooked into
page:view
this script