Audio element's play is postponed until the page goes into foreground
Reported by
skopin...@gmail.com,
Dec 11 2016
|
|||||
Issue descriptionChrome Version: <55.0.2883.87 64-bit> URLs (https://ru.999dice.com) : OS version: Windows 10 What steps will reproduce this crash (or if it's not reproducible, what were you doing just before the crash)? (1) open https://ru.999dice.com/ (2) f12 paste function soundz() { window.audio = {}; audio["alert"] = new Audio(); audio["alert"].src = "https://cdn.rawgit.com/hamboning/999dice-toys/master/codecx.wav"; window.audio["alert"].play(); return false; } flag_last_button = true; function AlertButton() { BtcRainButton = $(".Rain").text(); checkRainMax = (/BTC/i.test(BtcRainButton)); if (checkRainMax && flag_last_button) { soundz(); flag_last_button = false; } if (!checkRainMax) { flag_last_button = true; } } $('#ChatTab').bind('DOMSubtreeModified', AlertButton); (3) нужно подождать пока появится кнопка с текстом <btc|doge|ltc|eth> (появляется в чате раз в два часа или раньше)- (если переключиться на другую вкладку или свернуть браузер, то звук в скрипте при появлении кнопки не сработает, а если вернутся на страницу после появления кнопки на пару минут к примеру то звук сработает в момент перехода на эту страницу а не тогда когда появляется кнопка и в дальнейшем звук на кнопку срабатывает правильно.)
,
Dec 12 2016
,
Dec 12 2016
Added the Google Translate for point 3: 3) must wait until the button with the text appear <btc | doge | ltc | eth> (displayed in the chat every two hours or sooner) - (if you switch to another tab or minimize the browser, the sound in the script does not work with the appearance of a button, and if return to this page after the appearance of the buttons for a few minutes, for example the sound of fire when go to this page and not just when there is a button to continue to sound on button works properly.) skopin666@ : Thanks for the report.Could you please help with a minimised test case to triage further.
,
Dec 13 2016
The translation is pretty close to the text, except for the last bits about the sound of fire :) I think the problem here is delaying the sound because the page is in the background, I forget if we suspend play() until the page is visible or is it something about generic JS throttling that's enabled unless the page is making sound already. I think developers should use the Notifications API that has a way to specify a sound for notifications in the spec, see: https://notifications.spec.whatwg.org/#dom-notificationoptions-sound. However, there's no support for this feature yet according to MDN and it's in the backlog for the Chrome's notifications team with no ETA.
,
Dec 13 2016
I think we block the page from making noise if it never made sound while visible. I don't think we would do anything else on desktop.
,
Dec 16 2016
I think this is a won't fix then - we don't want pages to make sound from the background without user consent. Use Notifications API (whenever sound is supported) or use the page visibility API to stop making sounds when in the background. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by ajha@chromium.org
, Dec 12 2016