CreateJS / SoundJS

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.
http://createjs.com/
MIT License
4.42k stars 838 forks source link

Create soundInstance with audiobuffer or htmlAudioElement #294

Open KenilDomadia opened 6 years ago

KenilDomadia commented 6 years ago

Hello,

I am trying to play audio from downloaded zip of audio files in browser. I download the zip while starting the app and store ArrayBuffer in memory. I want to play the sound using these stored ArrayBuffer. I am facing the similar issue mentioned above as I am not able to find this feature in the version I'm using. Do we have support for playing the audio/creating soundInstance using ArrayBuffer? I'd really appreciate, if we have this feature as I do not want to shift to another library for doing the same. I am using createjs version 1.0.0. Thanks.

danzen commented 6 years ago

Hi folks,

Here is probably how we could play it without SoundJS but it would be good to have a way to play it with SoundJS (if there is not one already) https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/decodeAudioData

Howler accepts data - here is a message from their forum:

Howler will accept a data: URI structure, If the audioStream can be converted to a arrayBuffer, there is code available to Base64 encode it, then you could do something like:

howlSource = ["data:audio/mp3;base64,"+base64ArrayBuffer(arrayBuffer)]; soundPlayerObj = new Howl({ src: howlSource, });

It would be cool if it were the whole system so we could use PreloadJS to load and unzip and then make them available to play as their file names for IDs or some such thing. Otherwise, I guess it would just be a method to play an arrayBuffer that we would have to get ourselves from zip files.

lannymcnie commented 6 years ago

AudioBuffer support is already planned for SoundJS 2.0 (ES6), but might be worthwhile to add to version 1.0 as well if its a fairly straightforward feature.