-
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Web]: Mux video flickers when played on Safari #951
Comments
The flickering was really bothering me, so I played around with some fixes and found something that worked for me locally. Here’s what I ended up with—could you @mdumond try it out on your end and see if it resolves the issue for you too? Changes:1. Added a Dedicated Poster Layer const posterRef = useRef<HTMLDivElement>(null); <div ref={posterRef} className="absolute inset-0 z-0">
<img
className="h-full w-full object-cover"
src="https://image.mux.com/IPdwilTUVkKs2nK8zKZi5eKwbKhpCWxgsYNVxcANeFE/thumbnail.jpg?time=2"
alt="Video Poster"
/>
</div> 2. Managed Poster Visibility Dynamically useEffect(() => {
const video = videoElementRef.current;
if (playing && video) {
video.addEventListener('canplay', () => {
if (posterRef.current) {
posterRef.current.style.opacity = '0';
posterRef.current.style.transition = 'opacity 0.5s ease';
}
});
video.play();
} else {
video?.pause();
if (posterRef.current) {
posterRef.current.style.opacity = '1';
}
}
}, [playing]); 3. Some Layering for <MuxVideo
ref={videoElementRef}
className="h-full w-full object-cover z-10"
playbackId="IPdwilTUVkKs2nK8zKZi5eKwbKhpCWxgsYNVxcANeFE"
startTime={2}
loop
muted={muted}
autoPlay={playing}
playsInline
onCanPlay={() => setPlaying(true)}
> This worked for me—curious to know if it resolves the issue on your end as well or if it causes new problems. (one issue is now that when we press pause the poster image reappears, which is not optimal, but not really as bad as the white flickering) |
I'm testing this, for me when I pause the video and start it again, the video stays behind the poster image. If I revert locally
to
the pause behavior does not change, and the flickering at the start is not reverted |
Describe the bug
In Safari, the poster image flickers briefly before the video starts playing, causing a "not so smooth" transition.
Steps To Reproduce
No response
Expected Behavior
No response
Screenshots?
No response
Desktop Environment (please complete the following information)
Smartphone Type (please complete the following information)
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: