如何使用户手势遵循后期事件
我有一个带有iframe的网页(非公共),其中外页和iframe之间的关系为相同位置的跨源。要将事件从外页发送到内页,我正在使用 postmessage()呼叫。
这些事件会执行诸如内部页面上的Webaudio对象上启动播放的事情 - 它需要用户手势才能被视为“自动播放”,而“自动播放”会被浏览器阻止。
只要两个页面(外部和内部)都具有相同的文档属性,但是发送后播放事件开始播放效果很好,但是 document。
因此,当发送跨源互动的相同站点的邮政呼叫以在Chrome中启动音频播放 - 无document.domain。允许启动它。
问题似乎是用户手势与后听事件并未跟随。
从我可以在网络上收集的内容,Postmessage 应该仍然是在同一站点,跨原始页面之间拨打此类呼叫的工作方法,因此我不明白为什么它不起作用。有一些涉及此问题的错误报告( ),但是据我的理解,现在应该解决这个问题。
我尝试了消息通道API,该API仍在使用后,但没有得到任何不同的结果。
有解决方案吗? 在developer.chrome.com上,他们提到发送“原始代理群集:?0”标题作为“最后的度假胜地”,但这真的是这里唯一的解决方案吗?
I have a web page (non public) with an iframe, where the relation between outer page and iframe is same-site cross-origin. To send events from the outer page to the inner page, I'm using postMessage() calls.
The events do things such as start playback on a webAudio object in the inner page – which requires a user gesture in order to not be considered "auto play" which gets blocked by the browser.
Sending a postMessage event to start playback works fine as long as both pages (outer and inner) have the same document.domain property, but document.domain is deprecated and not a future-proof solution here. so I cannot rely on it.
So when sending a cross-origin same-site postMessage call to start audio playback in Chrome – without document.domain and without first clicking in the iframe in order to make an "interaction" with it – the response will be "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.".
The problem seems to be that user gestures are not following along with the postMessage event.
From what I can gather on the web, postMessage should still be a working method for making such calls between same-site, cross-origin pages, so I don't understand why it's not working. There are a few bug reports that touch upon this issue (such as this one), but to my understanding, the issue should be solved by now.
I have tried the Message Channel API, which still uses postMessage, and did not get any different results.
Is there a solution to this?
On developer.chrome.com they mention sending the "Origin-Agent-Cluster: ?0" header as a "last resort", but is this really the only solution here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论