I think this may be related to Changing <source> with HTML5 Audio works in Chrome but not Safari
The issue I'm having is that attaching a MediaSource to an Audio element in the background tab doesn't open the MediaSource the Audio element never starts playback.
Easily reproducible with the following jsbin: http://jsbin.com/haqexirege/edit?js,console
var mediaSource = new MediaSource();
mediaSource.addEventListener('sourceopen', function (data) {
console.log('media source opened', data);
});
console.log('script started');
setTimeout(function () {
console.log('timeout callback executed');
var audioElement = new Audio();
audioElement.src = URL.createObjectURL(mediaSource);
console.log('audio element attached to media source');
}, 5000);
- Open Dev tools in a separate window
- Click "Run" on the jsbin
- Open a new tab immediately so the jsbin tab is backgrounded
You'll see logs emitted in the console for every step of the code, but only when you put the tab in the foreground do you see the 'media source opened' log line.
Does anyone have a workaround for MediaSource?