[webkit-help] Autoplay Audio Issue in Safari for Cross-Origin Video Players
Jer Noble
jer.noble at apple.com
Mon Oct 28 15:47:57 PDT 2024
Hello premier.one,
WebKit uses the User Activation API <https://webkit.org/blog/13862/the-user-activation-api/> to detect whether the user has interacted with the page for the purpose of allowing audible auto-play. And as documented in that blog post, User Activation does not propagate to cross-origin frames.
All that said, I’m confused by this part of your email:
> ...occurs because our video content is hosted on a separate domain for technical reasons.
It looks like both your main content origin (https://premier.one) is the same origin as the video frame (/play/embed/…). So they should be Same-Origin rather than Cross-Origin.
I verified this with the Web Inspector:
> window.parent.location.origin === window.origin
< true
I also verified that you’re able to access the parent document from within your iframe context:
> window.parent.document.documentElement
< <html data-capo lang="ru" style="--vh: 4.46px;" class="scroll-lock">…</html>
So I’m confused why this might be true:
> window.parent.navigator.userActivation
< UserActivation {hasBeenActive: true, isActive: false}
> window.navigator.userActivation
< UserActivation {hasBeenActive: false, isActive: false}
It seems we may just have a bug in how we calculate User Activation. I’d recommend filing one on bugs.webkit.org for us to investigate.
-Jer
> On Oct 24, 2024, at 10:54 AM, iosdeveloper (premier.one) via webkit-help <webkit-help at lists.webkit.org> wrote:
>
> Dear WebKit Team,
>
> I am writing to seek your assistance with a persistent issue we've been facing with Safari's autoplay policy for cross-origin video content.
>
> Our Issue:
> We have been struggling with Safari's default behavior of muting autoplay video content when the media is hosted on a different domain than the main website. This is causing a suboptimal user experience for our customers using Safari.
>
> Specific Example:
> You can observe this issue on our website: https://premier.one/show/odin
> When a user clicks the yellow "play" button, the video starts but without audio. This occurs because our video content is hosted on a separate domain for technical reasons.
>
> Our Request:
> We kindly ask for your guidance or support in one of the following areas:
>
> 1. Is there a way to implement an exception for trusted domains within Safari's autoplay policy?
> 2. Can you suggest any improvements to our code that would allow audio autoplay for cross-origin content when explicitly triggered by user interaction?
> 3. Are there any upcoming features or policy changes in WebKit that might address this issue?
>
> We understand the importance of user-first policies and preventing unwanted audio experiences. However, in our case, the playback is always initiated by a clear user action, and the current behavior is leading to user confusion and support inquiries.
>
> We would greatly appreciate any insights, recommendations, or potential solutions you could provide to help us resolve this issue and improve our service for Safari users.
>
> Thank you for your time and consideration. We look forward to your response and any assistance you can offer.
> _______________________________________________
> webkit-help mailing list
> webkit-help at lists.webkit.org <mailto:webkit-help at lists.webkit.org>
> https://lists.webkit.org/mailman/listinfo/webkit-help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20241028/e0ff9af6/attachment.htm>
More information about the webkit-help
mailing list