function audioContextCheck() {
if (typeof Services.appShell.hiddenDOMWindow.AudioContext !== 'undefined') {
return new Services.appShell.hiddenDOMWindow.AudioContext();
} else if (typeof Services.appShell.hiddenDOMWindow.mozAudioContext !== 'undefined') {
return new Services.appShell.hiddenDOMWindow.mozAudioContext();
} else {
throw new Error('AudioContext not supported');
}
}
var pth = OS.Path.join(OS.Constants.Path.desktopDir, 'zirzir.mp3')
OS.File.read(pth).then(valRead => {
console.log('valRead:', valRead);
var myAudioContext = audioContextCheck();
//myAudioContext.decodeAudioData(valRead, function(buffer) {
var audioBuffer = valRead;
var playSound = myAudioContext.createBufferSource();
playSound.buffer = audioBuffer;
playSound.connect(myAudioContext.destination);
playSound.start(myAudioContext.currentTime);
//})
});
If you have a file on your desktop named zirzir.mp3
this works. But i rely on hiddenDOMWindow
, does anyone know how to do this without hiddenDOMWindow
to access AudioContext
?