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

Support for webm and weba files #212

Open lannymcnie opened 8 years ago

lannymcnie commented 8 years ago

Issue is described here: http://stackoverflow.com/questions/33216192/support-for-webm-and-weba-files-in-soundjs-and-preloadjs

lannymcnie commented 8 years ago

I did a quick test, and currently SoundJS determines that "weba" is not supported. This is based on the snippet in the Sound class that determines support, and you can test it in any browser console.

var audio = document.createElement("audio");
var canPlay = audio.canPlayType("audio/weba");
var ok = (canPlay != "no" && canPlay != "");

In Chrome, canPlayType("audio/weba") returns an empty string, which we consider to be a failure. Subbing in "webm", and it returns "maybe".

It is possible that this format is playable still, but we need to determine how to check for it. For example, the "m4a" extension is actually checked using "audio/mp4". There is an EXTENSION_MAP in SoundJS, which will map any additional extensions not specified in the SUPPORTED_EXTENSIONS to a specific type, and "weba" might have to be wired up like this.

Docs: http://createjs.com/docs/soundjs/classes/Sound.html#property_EXTENSION_MAP http://createjs.com/docs/soundjs/classes/Sound.html#property_SUPPORTED_EXTENSIONS