New Chrome Auto-Play policies breaking audio playback.

51 views
Skip to first unread message

BiffCornwall

unread,
May 4, 2018, 12:43:47 PM5/4/18
to StageXL
So Google has been rolling out their auto-play policy changes for audio and video. in Chrome v66.  We have several applications that use background audio, but even in the applications where audio does not play until the user clicks a button the audio playback is failing because we are loading the audio with the rest of the assets on page load.

From what I've read, if we want to be able to continue to load our audio assets on page load (we would absolutely prefer this) we have to tell the AudioContext to resume instead of play when the first instance of 'play' is called.  I believe this is something that would need to be updated in the StageXL framework, so I was hoping to get an idea of when we could expect a fix for this.

Thanks!

Bernhard Pichler

unread,
May 12, 2018, 4:38:02 AM5/12/18
to StageXL
Hi,

Do you have a prototype where this workaround actually works? If such a workaround works the whole auto-play policy would be pretty much useless because everyone could simply do this workaround. Also there is no real pause/resume feature in the AudioContext, a resume is just a new instance of the audio starting at a particular time (the time where you paused the audio before).

Bernhard

BiffCornwall

unread,
May 14, 2018, 1:39:11 PM5/14/18
to StageXL
Unfortunately I do not have a working example of this.  This was information obtained from the link in the OP.  Specifically:

"If you create your AudioContext on page load, you’ll have to call resume() later when user interacts with the page (e.g., user clicked a button)."
 
The resume would still have to occur after a user gesture.  Here is the example code offered in the document linked in the OP:

// Existing code unchanged.
window
.onload = function() {
 
var context = new AudioContext();
 
// Setup all nodes
 
...
}

// One-liner to resume playback when user interacted with the page.
document
.querySelector('button').addEventListener('click', function() {
  context
.resume().then(() => {
    console
.log('Playback resumed successfully');
 
});
});

I hope this helps!

Thanks!
Reply all
Reply to author
Forward
0 new messages