Comments on: Taking Web Audio Offline in iOS 6 Safari https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/ helping you implement HTML5 today Wed, 29 Jun 2016 01:58:29 +0000 hourly 1 By: Corey https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-2110894 Thu, 07 Apr 2016 15:05:09 +0000 http://html5doctor.com/?p=4812#comment-2110894 Great post! I think it’s worth mentioning that openssl needs the `-A` open to create a base64 encoding without line breaks. This way readers wont get confused when they try to wrap their encoding in quotes and run into EOF errors.

]]>
By: asquare https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-59291 Thu, 19 Jun 2014 18:35:54 +0000 http://html5doctor.com/?p=4812#comment-59291 Thank you! This article was super useful on a project about a year ago when I got the nasty surprise that audio wouldn’t play offline.

Revisiting the project again this year (and this article), I wanted to use kirilloid’s suggestion above but was having issues in webkit with the returned value not being a true ArrayBuffer. For whatever reason declaring the Uint8Array and ArrayBuffer separately appears to work in Chrome and Mobile Safari.

Something like the following is still nice and compact:


function decodeBase64ToArrayBuffer(base64str) {
var l = (base64str.length/4) * 3,
s = atob(base64str),
a = new ArrayBuffer(l),
b = new Uint8Array(a),
i;

for (i = 0; i &lt l; i++) b[i] = s.charCodeAt(i);
return a;
}

]]>
By: kirilloid https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-48078 Sun, 16 Feb 2014 03:27:51 +0000 http://html5doctor.com/?p=4812#comment-48078 Decoding base64 is much simpler (and possibly faster) with built-in `atob` function + `charCodeAt`:
function decodeBase64ToArrayBuffer(base64str) {
var l = (base64str.length/4) * 3,
s = atob(base64str),
a = new Uint8Array(new ArrayBuffer(l)),
i;
for (i = 0; i < l; i++) a[i] = s.charCodeAt(i);
return a;
}

]]>
By: Johnny https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-44484 Fri, 17 Jan 2014 07:00:44 +0000 http://html5doctor.com/?p=4812#comment-44484 Hi,
thanks for reply.
In a meanwhile I figured out what the problem was. After base64 encoding, you shall append ‘\n’ after every 64 chars.

]]>
By: Alex Gibson https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-44470 Thu, 16 Jan 2014 15:01:16 +0000 http://html5doctor.com/?p=4812#comment-44470 Excuse the typo, I meant to say in your JavaScript, not CSS obviously :)

]]>
By: Alex Gibson https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-44469 Thu, 16 Jan 2014 14:59:21 +0000 http://html5doctor.com/?p=4812#comment-44469 Hi Jonny,

I can’t see your example, but it sounds like you might have answered your own question? Just try using the base64 string on a single line in your CSS, as shown in the demo: https://github.com/alexgibson/offlinewebaudio/blob/master/sounds/ufo.js

]]>
By: Johnny https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-44420 Wed, 15 Jan 2014 08:13:05 +0000 http://html5doctor.com/?p=4812#comment-44420 Hey, it does work perfectly under Safari, but I have trouble to encode my own mp3 file and make it work. openssl base64 encoding outputs is a several lines of fixed length, which is recognised by browser as EOF. How exactly did you encode mp3 file to base64?
ps. copy pasting that base64 value and decoding this (back into binary file) also is not working for me. Am I missing something?

cheers,
Johnny

]]>
By: Alex Gibson https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-32094 Tue, 12 Mar 2013 07:42:47 +0000 http://html5doctor.com/?p=4812#comment-32094 Thanks for sharing, Adrian

Glad you like my home town :)

]]>
By: Adrian https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-32087 Tue, 12 Mar 2013 01:18:13 +0000 http://html5doctor.com/?p=4812#comment-32087 I was working on an all purpose in browser audio player recently, and I did something similar with the fileReader api. Using a file input box , I passed the data url into an audio element as source and it played just fine.
OpenSSL to do the encoding never occurred to me, great idea.

Here’s a demo.

http://fumatica.com/fumatic.html

By the way, I love Newcastle.
I spent a bunch of time over there
with a gorgeous Geordie girl.

Adrian

]]>
By: Peaches https://stevefaulkner.github.io/html5doctored/taking-web-audio-offline-in-ios-6-safari/#comment-32022 Sat, 09 Mar 2013 15:26:32 +0000 http://html5doctor.com/?p=4812#comment-32022 Great, you’ve just solved my problem. Thanks! I had spent a few hours banging my head against the wall on this one…

I have a button that sends an ajax request, and the confirmation sound needed to play on a successful response. I just put a false sound on the button click:

onclick="mySource.noteOn(1);mySource.noteOff();"

and now can play the sound via javascript in my response function.

Thanks for your help!

]]>