I'm creating a chrome app that decrypts mp3s sent from my PBX server to my gmail account and plays them. I have completed everything except for the audio player in gmail. I have two options:
- Use Web Audio API (I got it working but can't figure out how to make a fully functional seek bar).
- Create an createObjectURL from the array and pass to either audio tag or soundmanager2.
I want to reuse code as much as possible and haven't been able to find a pre-made Web Audio API player with seekbar. So, I attempted to try option 2 and the following is as far as I went
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var context = new AudioContext();
context.decodeAudioData(arr.buffer, function (soundBuffer) {
windowURL = window.URL || window.webkitURL;
var audio = document.createElement("audio");
audio.src = windowURL.createObjectURL([soundBuffer]);
var someDiv = document.getElementById("testDiv");
someDiv.appendChild(audio);
audio.onload = function (e) {
windowURL.revokeObjectURL(this.src);
}
}, function (err) {
console.log("couldnt decode buffer");
});
It fails with "Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided." How should I properly code this function to create an url that can used by chrome's mp3 player or soundmanager2?