在镀铬背景选项卡中自动播放声音 [英] Autoplay sound in chrome background tab

查看:128
本文介绍了在镀铬背景选项卡中自动播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用音频通知的HTML5游戏。

I have an HTML5 game that uses audio notifications.

当用户通过匹配查找其他玩家时,他们经常更改制表符以执行其他操作,并依靠音频通知知道什么时候回来。在Chrome(桌面)更改为禁止音频通知后,此功能不再有效。

When users are searching for other players with match-making they frequently change tabs to do other things and rely on the audio notification to know when to come back. This no longer works after Chrome (desktop) changed to disallow audio notifications.

如何确保音频通知在后台仍能正常工作?

How can I ensure the audio notifications still work in the background?

推荐答案

为我工作的解决方案是在页面加载后播放一个小的空白声(0.1秒就足够了)。之后,即使您切换到另一个标签,后台的标签仍然可以播放某些外部或内部事件中的声音。

The solution that worked for me was to play a small blank sound (0.1 second is enough) once the page is loaded. After that even if you switch to another tab, the tab in the background will still be able to play the sound on some external or internal event.

这篇关于在镀铬背景选项卡中自动播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆