Browse files

Updates to library

* Support for M4A
* Performance enhancements
* Placeholder WebAudio plugin (see /extras)
* Updated docs and minified file

Signed-off-by: Lanny McNie <lanny@gskinner.com>
  • Loading branch information...
1 parent 6623f36 commit 938486912e41185f9fa7a783cbca5ccc23ee5f4e @lannymcnie lannymcnie committed Nov 27, 2012
View
11 README.md
@@ -4,7 +4,7 @@ SoundJS is a library to make working with audio on the web easier. It provides a
## License
-It was built by gskinner.com, and is released for free under the MIT license, which means you can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a requirement.
+Built by gskinner.com, and released for free under the MIT license, which means you can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a requirement.
## Support and Resources
@@ -15,16 +15,17 @@ It was built by gskinner.com, and is released for free under the MIT license, wh
## Classes
-SoundJS
+### [SoundJS](http://createjs.com/Docs/SoundJS/SoundJS.html)
The core API for playing sounds. Simply call SoundJS.play(sound, options), and a sound instance is created that can be used to control the audio, and receive events when it is complete, loops, or is interrupted.
-SoundInstance
+### [SoundInstance](http://createjs.com/Docs/SoundJS/SoundInstance.html)
A controllable sound object that wraps the actual plugin implementation, providing a consistent API for audio playback, no matter what happens in the background. Sound instances can be paused, muted, and stopped, and the volume, pan (where available), and position using the simple API.
-HTMLAudioPlugin
+### [HTMLAudioPlugin](http://createjs.com/Docs/SoundJS/HTMLAudioPlugin.html)
The default, built-in plugin, which manages audio playback via the HTML5 <audio> tag.
-FlashPlugin
+### [FlashPlugin](http://createjs.com/Docs/SoundJS/FlashPlugin.html)
An additional plugin which uses a flash shim (and SWFObject) to playback audio using Flash.
+## [Documentation and examples](http://createjs.com/Docs/SoundJS/)
Have a look at the included examples and API documentation for more in-depth information.
View
3 VERSIONS.txt
@@ -2,6 +2,9 @@ Version NEXT
****************************************************************************************************
- Fixed issues with indexOf that were preventing stop/mute, etc.
- Fixed issue with initial mute state in FlashPlugin
+- A few major performance updates
+- Added support for M4A audio
+- Added WebAudio plugin in "extras". Official WebAudio support coming soon.
Version 0.3.0 [Aug 24, 2012]
****************************************************************************************************
View
2 dev/com/gskinner/soundjs/FlashAudioPlugin.as
@@ -1 +1 @@
-package com.gskinner.soundjs {
+package com.gskinner.soundjs {
View
BIN docs/SoundJS_docs-NEXT.zip
Binary file not shown.
View
2 examples/MediaPlayer.html
@@ -121,7 +121,7 @@
seeking = false;
$(this).unbind("mouseup mousemove");
var pos = $("#thumb").position().left/$("#track").width();
- instance.setPosition(pos*instance.getDuration());
+ instance.setPosition(pos*instance.getDuration()); // note that getDuration will return 0 if you have stopped the audio because of the way it handles tags
$("#blocker").remove();
});
});
View
2 examples/PreloadAndPlay.html
@@ -22,7 +22,7 @@
document.getElementById("header").style.display = "none";
}
- createjs.FlashPlugin.BASE_PATH = "../src/soundjs/" // Initialize the base path from this document to the Flash Plugin
+ createjs.FlashPlugin.BASE_PATH = "../src/soundjs/"; // Initialize the base path from this document to the Flash Plugin
if (!createjs.SoundJS.checkPlugin(true)) {
document.getElementById("error").style.display = "block";
document.getElementById("content").style.display = "none";
View
25 examples/SoundGrid.html
@@ -5,6 +5,7 @@
<script type="text/javascript" src="./assets/preloadjs-0.2.0.min.js"></script>
+ <script type="text/javascript" src="../extras/WebAudioPlugin.js"></script>
<script type="text/javascript" src="../src/soundjs/SoundJS.js"></script>
<script type="text/javascript" src="../src/soundjs/HTMLAudioPlugin.js"></script>
<script type="text/javascript" src="../src/swfobject.js"></script>
@@ -31,21 +32,21 @@
document.getElementById("loader").className = "loader";
var assetsPath = "assets/";
var manifest = [
- {src:assetsPath+"Game-Break.mp3|"+assetsPath+"Game-Break.ogg", id:1, data: 1},
- {src:assetsPath+"Game-Spawn.mp3|"+assetsPath+"Game-Spawn.ogg", id:2, data: 1},
- {src:assetsPath+"Game-Shot.mp3|"+assetsPath+"Game-Shot.ogg", id:3, data: 1},
+ {src:assetsPath+"Game-Break.mp3|"+assetsPath+"Game-Break.ogg", id:1},
+ {src:assetsPath+"Game-Spawn.mp3|"+assetsPath+"Game-Spawn.ogg", id:2},
+ {src:assetsPath+"Game-Shot.mp3|"+assetsPath+"Game-Shot.ogg", id:3},
- {src:assetsPath+"GU-StealDaisy.mp3|"+assetsPath+"GU-StealDaisy.ogg", id:4, data: 1},
- {src:assetsPath+"Humm.mp3|"+assetsPath+"Humm.ogg", id:5, data: 1},
- {src:assetsPath+"R-Damage.mp3|"+assetsPath+"R-Damage.ogg", id:6, data: 1},
+ {src:assetsPath+"GU-StealDaisy.mp3|"+assetsPath+"GU-StealDaisy.ogg", id:4},
+ {src:assetsPath+"Humm.mp3|"+assetsPath+"Humm.ogg", id:5},
+ {src:assetsPath+"R-Damage.mp3|"+assetsPath+"R-Damage.ogg", id:6},
- {src:assetsPath+"Thunder1.mp3|"+assetsPath+"Thunder1.ogg", id:7, data: 1},
- {src:assetsPath+"S-Damage.mp3|"+assetsPath+"S-Damage.ogg", id:8, data: 1},
- {src:assetsPath+"U-CabinBoy3.mp3|"+assetsPath+"U-CabinBoy3.ogg", id:9, data: 1},
+ {src:assetsPath+"Thunder1.mp3|"+assetsPath+"Thunder1.ogg", id:7},
+ {src:assetsPath+"S-Damage.mp3|"+assetsPath+"S-Damage.ogg", id:8},
+ {src:assetsPath+"U-CabinBoy3.mp3|"+assetsPath+"U-CabinBoy3.ogg", id:9},
- {src:assetsPath+"ToneWobble.mp3|"+assetsPath+"ToneWobble.ogg", id:10, data: 1},
- {src:assetsPath+"Game-Death.mp3|"+assetsPath+"Game-Death.ogg", id:11, data: 1},
- {src:assetsPath+"Game-Break.mp3|"+assetsPath+"Game-Break.ogg", id:12, data: 1}
+ {src:assetsPath+"ToneWobble.mp3|"+assetsPath+"ToneWobble.ogg", id:10},
+ {src:assetsPath+"Game-Death.mp3|"+assetsPath+"Game-Death.ogg", id:11},
+ {src:assetsPath+"Game-Break.mp3|"+assetsPath+"Game-Break.ogg", id:12}
];
preload = new createjs.PreloadJS();
View
157 examples/SoundGrid_WebAudio.html
@@ -0,0 +1,157 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>SoundJS: Sound Grid</title>
+
+ <script type="text/javascript" src="./assets/preloadjs-0.2.0.min.js"></script>
+
+ <script type="text/javascript" src="../extras/WebAudioPlugin.js"></script>
+ <script type="text/javascript" src="../src/soundjs/SoundJS.js"></script>
+ <script type="text/javascript" src="../src/soundjs/HTMLAudioPlugin.js"></script>
+ <script type="text/javascript" src="../src/swfobject.js"></script>
+ <script type="text/javascript" src="../src/soundjs/FlashPlugin.js"></script>
+
+ <!-- We also provide hosted minified versions of all CreateJS libraries.
+ http://code.createjs.com -->
+
+ <script>
+ var preload;
+
+ function init() {
+ if (window.top != window) {
+ document.getElementById("header").style.display = "none";
+ }
+
+ // Register the webaudio plugin as the default. Please see the /extras folder to find the WebAudio plugin.
+ createjs.SoundJS.registerPlugins([WebAudioPlugin, createjs.HTMLAudioPlugin]);
+
+ createjs.FlashPlugin.BASE_PATH = "../src/soundjs/" // Initialize the base path from this document to the Flash Plugin
+ if (!createjs.SoundJS.checkPlugin(true)) {
+ document.getElementById("error").style.display = "block";
+ document.getElementById("content").style.display = "none";
+ return;
+ }
+
+ document.getElementById("loader").className = "loader";
+ var assetsPath = "assets/";
+ var manifest = [
+ {src:assetsPath+"Game-Break.mp3|"+assetsPath+"Game-Break.ogg", id:1, data: 1},
+ {src:assetsPath+"Game-Spawn.mp3|"+assetsPath+"Game-Spawn.ogg", id:2, data: 1},
+ {src:assetsPath+"Game-Shot.mp3|"+assetsPath+"Game-Shot.ogg", id:3, data: 1},
+
+ {src:assetsPath+"GU-StealDaisy.mp3|"+assetsPath+"GU-StealDaisy.ogg", id:4, data: 1},
+ {src:assetsPath+"Humm.mp3|"+assetsPath+"Humm.ogg", id:5, data: 1},
+ {src:assetsPath+"R-Damage.mp3|"+assetsPath+"R-Damage.ogg", id:6, data: 1},
+
+ {src:assetsPath+"Thunder1.mp3|"+assetsPath+"Thunder1.ogg", id:7, data: 1},
+ {src:assetsPath+"S-Damage.mp3|"+assetsPath+"S-Damage.ogg", id:8, data: 1},
+ {src:assetsPath+"U-CabinBoy3.mp3|"+assetsPath+"U-CabinBoy3.ogg", id:9, data: 1},
+
+ {src:assetsPath+"ToneWobble.mp3|"+assetsPath+"ToneWobble.ogg", id:10, data: 1},
+ {src:assetsPath+"Game-Death.mp3|"+assetsPath+"Game-Death.ogg", id:11, data: 1},
+ {src:assetsPath+"Game-Break.mp3|"+assetsPath+"Game-Break.ogg", id:12, data: 1}
+ ];
+
+ preload = new createjs.PreloadJS();
+ //Install SoundJS as a plugin, then PreloadJS will initialize it automatically.
+ preload.installPlugin(createjs.SoundJS);
+
+ //Available PreloadJS callbacks
+ preload.onFileLoad = function(event) {
+ // Show the icon on loaded items.
+ var div = document.getElementById(event.id);
+ div.style.backgroundImage = "url('assets/audioButtonSheet.png')";
+ };
+ preload.onComplete = function(event) {
+ document.getElementById("loader").className = "";
+ }
+
+ //Load the manifest and pass 'true' to start loading immediately. Otherwise, you can call load() manually.
+ preload.loadManifest(manifest, true);
+ }
+
+ function stop() {
+ if (preload != null) { preload.close(); }
+ createjs.SoundJS.stop();
+ }
+
+ function playSound(target) {
+ //Play the sound: play (src, interrupt, delay, offset, loop, volume, pan)
+ var instance = createjs.SoundJS.play(target.id, createjs.SoundJS.INTERRUPT_NONE, 0, 0, false, 1);
+ if (instance == null || instance.playState == createjs.SoundJS.PLAY_FAILED) { return; }
+ target.className = "gridBox active";
+ instance.onComplete = function(instance) {
+ target.className = "gridBox";
+ }
+
+ }
+ </script>
+
+ <link rel="stylesheet" type="text/css" href="assets/demoStyles.css"/>
+ <style>
+ body {
+ font-family: sans-serif;
+ font-size: 11px;
+ }
+
+ #content {
+ width: 1000px;
+ }
+ .gridBox {
+ float: left;
+ background-repeat: no-repeat;
+ background-position: 0 0px;
+ background-color: #222;
+ background-size: 320px 300px;
+ border: 0px solid #666;
+ width: 320px;
+ height: 100px;
+ }
+ .gridBox:hover {
+ background-position: 0 -100px;
+ background-color: #322;
+ cursor: pointer;
+ }
+ .gridBox.active, .gridbox.active:hover {
+ background-position: 0 -200px;
+ cursor: auto;
+ }
+ </style>
+
+</head>
+
+<body onload="init();">
+
+ <div id="loader"></div>
+
+ <header id="header" class="SoundJS">
+ <h1><span class="text-product">Sound<strong>JS</strong></span> Sound Grid</h1>
+ <p>Click audio instances in the grid to play them.</p>
+ </header>
+
+ <!-- We'll use the ID of the div to determine which audio file to play.
+ These id's match the ones passed into the audioList array. -->
+ <div id="content">
+ <div id="1" onclick="playSound(this)" class="gridBox"></div>
+ <div id="2" onclick="playSound(this)" class="gridBox"></div>
+ <div id="3" onclick="playSound(this)" class="gridBox"></div>
+ <div id="4" onclick="playSound(this)" class="gridBox"></div>
+ <div id="5" onclick="playSound(this)" class="gridBox"></div>
+ <div id="6" onclick="playSound(this)" class="gridBox"></div>
+ <div id="7" onclick="playSound(this)" class="gridBox"></div>
+ <div id="8" onclick="playSound(this)" class="gridBox"></div>
+ <div id="9" onclick="playSound(this)" class="gridBox"></div>
+ <div id="10" onclick="playSound(this)" class="gridBox"></div>
+ <div id="11" onclick="playSound(this)" class="gridBox"></div>
+ <div id="12" onclick="playSound(this)" class="gridBox"></div>
+ </div>
+
+ <div id="error">
+ <h1>Sorry!</h1>
+ <p>SoundJS is not currently supported in your browser.</p>
+ <p>We are currently working on support for iOS. Please <a href="http://github.com/CreateJS/SoundJS/issues" target="_blank">log a bug</a>
+ if you see this in any other browsers.</p>
+ </div>
+
+</body>
+</html>
View
4 examples/TestSuite.html
@@ -151,6 +151,8 @@
var value = $(this).slider("option", "value");
instance.setPan(value/100);
});
+
+ removeSound("all"); //disable instance volume, pan, pause, and stop on startup
}
function stop() {
@@ -201,7 +203,7 @@
// Play Sound
var instance = createjs.SoundJS.play(item.value, interruptValue, delay, offset, loop, 1, 0);
- if (instance == null) { continue; }
+ if (instance == null || instance.playState == createjs.SoundJS.PLAY_FAILED) { continue; }
instance.onPlayFailed = handlePlayFailed;
instance.onComplete = handleSoundComplete;
instance.onPlayInterrupted = handlePlayFailed;
View
275 extras/WebAudioPlugin.js
@@ -0,0 +1,275 @@
+/*
+* WebAudioPlugin for SoundJS
+* Visit http://createjs.com/ for documentation, updates and examples.
+*
+* Copyright (c) 2012 Christoph Martens (@martensms)
+*
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/*
+ * WebAudio Plugin provided by Zynga developer Sascha Goebel
+ * https://github.com/CreateJS/SoundJS/pull/15
+ *
+ * This plugin only provides simple play/complete functionality, as well as internally
+ * loading all required sounds.
+ *
+ * A fully functional WebAudio plugin will be included in the next release of SoundJS.
+ */
+
+(function(window) {
+
+ function WebAudioPlugin() {
+ this.init();
+ }
+
+ var s = WebAudioPlugin;
+
+ s.isSupported = function() {
+
+ s.generateCapabilities();
+ var context = s.context;
+ if (context == null) { return false; }
+
+ return true;
+
+ };
+
+ s.generateCapabilities = function() {
+
+ if (s.capabilities != null) { return; }
+
+ var audio = null;
+
+ if (typeof Audio == "function") {
+ audio = new Audio(); // could use instead -> document.createElement("audio");
+ }
+
+ if(typeof AudioContext == "function") {
+ s.context = new AudioContext();
+ } else if (typeof webkitAudioContext == "function") {
+ s.context = new webkitAudioContext();
+ }
+
+ if (audio && s.context) {
+ s.capabilities = {
+ panning: false,
+ volume: true,
+ mp3: audio.canPlayType("audio/mp3") != "no" && audio.canPlayType("audio/mp3") != "",
+ ogg: audio.canPlayType("audio/ogg") != "no" && audio.canPlayType("audio/ogg") != "",
+ mpeg: audio.canPlayType("audio/mpeg") != "no" && audio.canPlayType("audio/mpeg") != "",
+ wav:audio.canPlayType("audio/wav") != "no" && audio.canPlayType("audio/wav") != "",
+ mp4: audio.canPlayType("audio/mp4") != "no" && audio.canPlayType("audio/mp4") != "",
+ channels: 20
+ };
+ }
+
+ }
+
+ var _buffers = {}; // TODO: change this to reside in the prototype or class scope
+
+ var p = WebAudioPlugin.prototype = {
+
+ capabilities: null,
+
+ init: function() {
+ this.capabilities = WebAudioPlugin.capabilities;
+ this.channels = {};
+ },
+
+ register: function(src, instances) {
+ // https://github.com/CreateJS/PreloadJS/issues/14
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', src);
+ xhr.responseType = 'arraybuffer';
+
+ xhr.onload = function(event) {
+ // Note: We need to lookup buffers by their source, so we need a better way to reference them
+ // then the nested anonymous functions.
+ WebAudioPlugin.context.decodeAudioData(event.target.response,
+ function(buffer) {
+ _buffers[src] = buffer;
+ });
+ }
+
+
+
+ xhr.send(null);
+ },
+
+
+ create: function(src) {
+ var instance = new SoundInstance(src);
+ instance.owner = this;
+ return instance;
+
+ }
+
+ }
+
+ window.WebAudioPlugin = WebAudioPlugin;
+
+ function SoundInstance(src) {
+ this.init(src);
+ }
+
+ var p = SoundInstance.prototype = {
+
+ init: function(src) {
+ this.src = src;
+ this.muted = false;
+ this.volume = 1;
+ this.playState = null;
+ this.onComplete = null;
+ this.lastPlaybackCurrentTime = null;
+
+ this.gainNode = WebAudioPlugin.context.createGainNode();
+ this.gainNode.gain.value = this.volume;
+
+ },
+
+ interrupt: function () {
+ //TODO: This should stop the audio. See HTMLAudioPlugin for usage.
+ },
+
+
+ // Public API
+ play: function(interrupt, delay, offset, loop, volume, pan) {
+ createjs.SoundJS.playInstance(this, interrupt, delay, offset, loop, volume, pan);
+ },
+
+ // Called by SoundJS when ready
+ beginPlaying: function(offset, loop, volume, pan) {
+ if (volume !== this.volume) {
+ this.volume = volume;
+ this.updateVolume()
+ }
+
+ var source = WebAudioPlugin.context.createBufferSource();
+ source.buffer = _buffers[this.src];
+ source.connect(this.gainNode);
+ source.connect(WebAudioPlugin.context.destination);
+
+ source.noteOn(WebAudioPlugin.context.currentTime);
+
+ this.lastPlaybackCurrentTime = WebAudioPlugin.context.currentTime;
+
+ setTimeout(createjs.SoundJS.proxy(this.handlePlaybackComplete, this), source.buffer.duration*1000);
+
+ //LM: Should we do this?
+ if (loop === true) {
+ source.loop = true;
+ }
+
+ return 1;
+
+ },
+
+ handlePlaybackComplete: function() {
+ this.playState = createjs.SoundJS.PLAY_FINISHED;
+ this.lastPlayback = null;
+ if (this.onComplete != null) { this.onComplete(this); }
+ },
+
+ pause: function() {
+ //TODO
+ },
+
+ resume: function() {
+ //TODO
+ },
+
+ stop: function() {
+ //TODO
+ this.playState = createjs.SoundJS.PLAY_FINISHED;
+ return true;
+ },
+
+ // Called by SoundJS
+ setMasterVolume: function(value) {
+ //TODO
+ this.updateVolume();
+ return true;
+ },
+
+ setVolume: function(value) {
+ this.volume = value;
+ this.updateVolume();
+ return true;
+ },
+
+ updateVolume: function() {
+ if (this.gainNode !== null) {
+ this.gainNode.gain.value = this.muted ? 0 : this.volume * createjs.SoundJS.masterVolume;
+ return true;
+ } else {
+ return false;
+ }
+
+ },
+
+ getVolume: function(value) {
+ return this.volume;
+ },
+
+ mute: function(isMuted) {
+ this.muted = isMuted;
+ this.updateVolume();
+ return true;
+ },
+
+
+ setPan: function(value) { return false; },
+ getPan: function() { return 0; },
+
+ getPosition: function() {
+ if (this.lastPlaybackCurrentTime !== null) {
+ return WebAudioPlugin.context.currentTime - this.lastPlaybackCurrentTime;
+ } else {
+ return 0;
+ }
+ },
+
+ setPosition: function(value) { return false; },
+
+ getDuration: function() {
+ if (_buffers[this.src]) {
+ return _buffers[this.src].duration;
+ } else {
+ return 0;
+ }
+ },
+
+ // Play has failed
+ playFailed: function() {
+ if (window.createjs == null) { return; }
+ this.playState = createjs.SoundJS.PLAY_FAILED;
+ if (this.onPlayFailed != null) { this.onPlayFailed(this); }
+ },
+
+ toString: function() {
+ return "[WebAudio SoundInstance]";
+ }
+
+ }
+
+}(window));
View
49 lib/soundjs-NEXT.min.js
@@ -10,27 +10,28 @@
* This notice shall be included in all copies or substantial portions of the Software.
**/
this.createjs=this.createjs||{};
-(function(){function b(){throw"SoundJS cannot be instantiated";}function f(a,b){this.init(a,b)}function d(){}b.DELIMITER="|";b.AUDIO_TIMEOUT=8E3;b.INTERRUPT_ANY="any";b.INTERRUPT_EARLY="early";b.INTERRUPT_LATE="late";b.INTERRUPT_NONE="none";b.PLAY_INITED="playInited";b.PLAY_SUCCEEDED="playSucceeded";b.PLAY_INTERRUPTED="playInterrupted";b.PLAY_FINISHED="playFinished";b.PLAY_FAILED="playFailed";b.activePlugin=null;b.muted=false;b.pluginsRegistered=false;b.masterVolume=1;b.instances=[];b.instanceHash=
-{};b.idHash=null;b.defaultSoundInstance=null;b.getPreloadHandlers=function(){return{callback:b.proxy(b.initLoad,b),types:["sound"],extensions:["mp3","ogg","wav"]}};b.registerPlugins=function(a){b.pluginsRegistered=true;for(var g=0,c=a.length;g<c;g++){var e=a[g];if(e!=null&&e.isSupported())return b.activePlugin=new e,true}return false};b.registerPlugin=function(a){b.pluginsRegistered=true;if(a==null)return false;return a.isSupported()?(b.activePlugin=new a,true):false};b.isReady=function(){return b.activePlugin!=
-null};b.getCapabilities=function(){return b.activePlugin==null?null:b.activePlugin.capabilities};b.getCapability=function(a){return b.activePlugin==null?null:b.activePlugin.capabilities[a]};b.initLoad=function(a,g,c,e){if(!b.checkPlugin(true))return false;a=b.parsePath(a,g,c,e);if(a==null)return false;if(c!=null){if(b.idHash==null)b.idHash={};b.idHash[c]=a.src}f.create(a.src,e);c=b.activePlugin.register(a.src,e);if(c!=null){if(c.tag!=null)a.tag=c.tag;else if(c.src)a.src=c.src;if(c.completeHandler!=
-null)a.handler=c.completeHandler}return a};b.parsePath=function(a,g,c,e){for(var a=a.split(b.DELIMITER),g={type:g||"sound",id:c,data:e,handler:b.handleSoundReady},c=false,e=b.getCapabilities(),h=0,d=a.length;h<d;h++){var f=a[h],i=f.lastIndexOf("."),k=f.substr(i+1).toLowerCase(),i=f.substr(0,i).split("/").pop();switch(k){case "mp3":e.mp3&&(c=true);break;case "ogg":e.ogg&&(c=true);break;case "wav":e.wav&&(c=true)}if(c)return g.name=i,g.src=f,g.extension=k,g}return null};b.play=function(a,g,c,e,h,f,
-d){if(!b.checkPlugin(true))return b.defaultSoundInstance;a=b.getSrcFromId(a);a=b.activePlugin.create(a);try{a.mute(b.muted)}catch(i){}b.playInstance(a,g,c,e,h,f,d)||a.playFailed();return a};b.playInstance=function(a,g,c,e,h,f,d){g=g||b.INTERRUPT_NONE;c==null&&(c=0);e==null&&(e=0);h==null&&(h=0);f==null&&(f=1);d==null&&(d=0);if(c==0){if(!b.beginPlaying(a,g,e,h,f,d))return false}else setTimeout(function(){b.beginPlaying(a,g,e,h,f,d)},c);this.instances.push(a);this.instanceHash[a.uniqueId]=a;return true};
-b.beginPlaying=function(a,b,c,e,d,j){if(!f.add(a,b))return false;return!a.beginPlaying(c,e,d,j)?(b=this.instances.indexOf(a),b>-1&&this.instances.splice(b,1),delete this.instanceHash[a.uniqueId],false):true};b.checkPlugin=function(a){return b.activePlugin==null&&(a&&!b.pluginsRegistered&&b.registerPlugin(createjs.HTMLAudioPlugin),b.activePlugin==null)?false:true};b.getSrcFromId=function(a){return b.idHash==null||b.idHash[a]==null?a:b.idHash[a]};b.setVolume=function(a,g){if(Number(a)==null)return false;
-a=Math.max(0,Math.min(1,a));return b.tellAllInstances("setVolume",g,a)};b.getMasterVolume=function(){return b.masterVolume};b.setMasterVolume=function(a){b.masterVolume=a;return b.tellAllInstances("setMasterVolume",null,a)};b.setMute=function(a){this.muted=a;return b.tellAllInstances("mute",null,a)};b.pause=function(a){return b.tellAllInstances("pause",a)};b.resume=function(a){return b.tellAllInstances("resume",a)};b.stop=function(a){return b.tellAllInstances("stop",a)};b.getInstanceById=function(a){return this.instanceHash[a]};
-b.playFinished=function(a){f.remove(a);a=this.instances.indexOf(a);a>-1&&this.instances.splice(a,1)};b.tellAllInstances=function(a,b,c){if(this.activePlugin==null)return false;for(var b=this.getSrcFromId(b),e=this.instances.length-1;e>=0;e--){var d=this.instances[e];if(!(b!=null&&d.src!=b))switch(a){case "pause":d.pause();break;case "resume":d.resume();break;case "setVolume":d.setVolume(c);break;case "setMasterVolume":d.setMasterVolume(c);break;case "mute":d.mute(c);break;case "stop":d.stop();break;
-case "setPan":d.setPan(c)}}return true};b.proxy=function(a,b){return function(){return a.apply(b,arguments)}};createjs.SoundJS=b;f.channels={};f.create=function(a,b){var c=f.get(a);c==null?f.channels[a]=new f(a,b):c.max+=b};f.add=function(a,b){var c=f.get(a.src);return c==null?false:c.add(a,b)};f.remove=function(a){var b=f.get(a.src);if(b==null)return false;b.remove(a);return true};f.get=function(a){return f.channels[a]};f.prototype={src:null,max:null,length:0,init:function(a,b){this.src=a;this.max=
-b||1;this.instances=[]},get:function(a){return this.instances[a]},add:function(a,b){if(!this.getSlot(b,a))return false;this.instances.push(a);this.length++;return true},remove:function(a){a=this.instances.indexOf(a);if(a==-1)return false;this.instances.splice(a,1);this.length--;return true},getSlot:function(a){for(var g,c,e=0,d=this.max||100;e<d;e++){g=this.get(e);if(g==null)return true;else if(a==b.INTERRUPT_NONE)continue;if(e==0)c=g;else if(g.playState==b.PLAY_FINISHED||g==b.PLAY_INTERRUPTED||g==
-b.PLAY_FAILED)c=g;else if(a==b.INTERRUPT_EARLY&&g.getPosition()<c.getPosition()||a==b.INTERRUPT_LATE&&g.getPosition()>c.getPosition())c=g}return c!=null?(c.interrupt(),this.remove(c),true):false},toString:function(){return"[SoundJS SoundChannel]"}};b.defaultSoundInstance=new function(){this.isDefault=true;this.pause=this.resume=this.play=this.beginPlaying=this.cleanUp=this.interrupt=this.stop=this.setMasterVolume=this.setVolume=this.mute=this.setPan=this.getPosition=this.setPosition=this.playFailed=
-function(){return false};this.getVolume=this.getPan=this.getDuration=function(){return 0};this.playState=b.PLAY_FAILED;this.toString=function(){return"[SoundJS Default Sound Instance]"}};d.init=function(){var a=navigator.userAgent;d.isFirefox=a.indexOf("Firefox")>-1;d.isOpera=window.opera!=null;d.isIOS=a.indexOf("iPod")>-1||a.indexOf("iPhone")>-1||a.indexOf("iPad")>-1};d.init();createjs.SoundJS.BrowserDetect=d})();this.createjs=this.createjs||{};
-(function(){function b(){this.init()}function f(a){this.init(a)}function d(a){this.init(a)}b.MAX_INSTANCES=30;b.capabilities=null;b.lastId=0;b.AUDIO_READY="canplaythrough";b.AUDIO_ENDED="ended";b.AUDIO_ERROR="error";b.AUDIO_STALLED="stalled";b.fillChannels=false;b.isSupported=function(){if(createjs.SoundJS.BrowserDetect.isIOS)return false;b.generateCapabilities();return b.tag==null?false:true};b.generateCapabilities=function(){if(b.capabilities==null){var a=b.tag=document.createElement("audio");if(a.canPlayType==
-null)return null;b.capabilities={panning:false,volume:true,mp3:a.canPlayType("audio/mp3")!="no"&&a.canPlayType("audio/mp3")!="",ogg:a.canPlayType("audio/ogg")!="no"&&a.canPlayType("audio/ogg")!="",mpeg:a.canPlayType("audio/mpeg")!="no"&&a.canPlayType("audio/mpeg")!="",wav:a.canPlayType("audio/wav")!="no"&&a.canPlayType("audio/wav")!="",channels:b.MAX_INSTANCES}}};b.prototype={capabilities:null,FT:0.0010,channels:null,init:function(){this.capabilities=b.capabilities;this.channels={}},register:function(a,
-b){for(var c=d.get(a),e,f=0,j=b||1;f<j;f++)e=this.createTag(a),c.add(e);return{tag:e}},createTag:function(a){var b=document.createElement("audio");b.preload=false;b.src=a;return b},create:function(a){a=new f(a);a.owner=this;return a},toString:function(){return"[HTMLAudioPlugin]"}};createjs.HTMLAudioPlugin=b;f.prototype={src:null,uniqueId:-1,playState:null,owner:null,loaded:false,lastInterrupt:createjs.SoundJS.INTERRUPT_NONE,offset:0,delay:0,volume:1,pan:0,remainingLoops:0,delayTimeout:-1,tag:null,
-muted:false,paused:false,onComplete:null,onLoop:null,onReady:null,onPlayFailed:null,onPlayInterrupted:null,endedHandler:null,readyHandler:null,stalledHandler:null,init:function(a){this.uniqueId=createjs.HTMLAudioPlugin.lastId++;this.src=a;this.endedHandler=createjs.SoundJS.proxy(this.handleSoundComplete,this);this.readyHandler=createjs.SoundJS.proxy(this.handleSoundReady,this);this.stalledHandler=createjs.SoundJS.proxy(this.handleSoundStalled,this)},cleanUp:function(){var a=this.tag;if(a!=null){a.pause();
-try{a.currentTime=0}catch(b){}a.removeEventListener(createjs.HTMLAudioPlugin.AUDIO_ENDED,this.endedHandler,false);a.removeEventListener(createjs.HTMLAudioPlugin.AUDIO_READY,this.readyHandler,false);d.setInstance(this.src,a);this.tag=null}window.createjs!=null&&createjs.SoundJS.playFinished(this)},interrupt:function(){if(this.tag!=null){this.playState=createjs.SoundJS.PLAY_INTERRUPTED;if(this.onPlayInterrupted)this.onPlayInterrupted(this);this.cleanUp();this.paused=false}},play:function(a,b,c,e,d,
-f){this.cleanUp();createjs.SoundJS.playInstance(this,a,b,c,e,d,f)},beginPlaying:function(a,b,c){if(window.createjs!=null){var e=this.tag=d.getInstance(this.src);if(e==null)return this.playFailed(),-1;e.addEventListener(createjs.HTMLAudioPlugin.AUDIO_ENDED,this.endedHandler,false);this.offset=a;this.volume=c;this.updateVolume();this.remainingLoops=b;e.readyState!==4?(e.addEventListener(createjs.HTMLAudioPlugin.AUDIO_READY,this.readyHandler,false),e.addEventListener(createjs.HTMLAudioPlugin.AUDIO_STALLED,
-this.stalledHandler,false),e.load()):this.handleSoundReady(null);return 1}},handleSoundStalled:function(){if(this.onPlayFailed!=null)this.onPlayFailed(this);this.cleanUp()},handleSoundReady:function(){if(window.createjs!=null)if(this.playState=createjs.SoundJS.PLAY_SUCCEEDED,this.paused=false,this.tag.removeEventListener(createjs.HTMLAudioPlugin.AUDIO_READY,this.readyHandler,false),this.offset>=this.getDuration())this.playFailed();else{if(this.offset>0)this.tag.currentTime=this.offset*0.0010;if(this.remainingLoops==
--1)this.tag.loop=true;this.tag.play()}},pause:function(){this.paused=true;return this.tag!=null?(this.tag.pause(),false):true},resume:function(){this.paused=false;return this.tag!=null?(this.tag.play(),false):true},stop:function(){this.pause();this.playState=createjs.SoundJS.PLAY_FINISHED;this.cleanUp();return true},setMasterVolume:function(){this.updateVolume();return true},setVolume:function(a){this.volume=a;this.updateVolume();return true},updateVolume:function(){return this.tag!=null?(this.tag.volume=
-this.muted?0:this.volume*createjs.SoundJS.masterVolume,true):false},getVolume:function(){return this.volume},mute:function(a){this.muted=a;this.updateVolume();return true},setPan:function(){return false},getPan:function(){return 0},getPosition:function(){return this.tag==null?0:this.tag.currentTime*1E3},setPosition:function(a){if(this.tag==null)return false;try{this.tag.currentTime=a*0.0010}catch(b){return false}return true},getDuration:function(){return this.tag==null?0:this.tag.duration*1E3},handleSoundComplete:function(){if(this.remainingLoops!=
-0){if(this.remainingLoops--,this.tag.play(),this.onLoop!=null)this.onLoop(this)}else if(window.createjs!=null){this.playState=createjs.SoundJS.PLAY_FINISHED;if(this.onComplete!=null)this.onComplete(this);this.cleanUp()}},playFailed:function(){if(window.createjs!=null){this.playState=createjs.SoundJS.PLAY_FAILED;if(this.onPlayFailed!=null)this.onPlayFailed(this);this.cleanUp()}},toString:function(){return"[HTMLAudioPlugin SoundInstance]"}};d.channels={};d.get=function(a){var b=d.channels[a];b==null&&
-(b=d.channels[a]=new d(a));return b};d.getInstance=function(a){a=d.channels[a];return a==null?null:a.get()};d.setInstance=function(a,b){var c=d.channels[a];return c==null?null:c.set(b)};d.prototype={src:null,length:0,available:0,tags:null,init:function(a){this.src=a;this.tags=[]},add:function(a){this.tags.push(a);this.length++;this.available=this.tags.length},get:function(){if(this.tags.length==0)return null;this.available=this.tags.length;var a=this.tags.pop();document.body.appendChild(a);return a},
-set:function(a){this.tags.indexOf(a)==-1&&this.tags.push(a);document.body.removeChild(a);this.available=this.tags.length},toString:function(){return"[HTMLAudioPlugin TagChannel]"}}})();
+(function(){function b(){throw"SoundJS cannot be instantiated";}function f(a,b){this.init(a,b)}function e(){}b.DELIMITER="|";b.AUDIO_TIMEOUT=8E3;b.INTERRUPT_ANY="any";b.INTERRUPT_EARLY="early";b.INTERRUPT_LATE="late";b.INTERRUPT_NONE="none";b.PLAY_INITED="playInited";b.PLAY_SUCCEEDED="playSucceeded";b.PLAY_INTERRUPTED="playInterrupted";b.PLAY_FINISHED="playFinished";b.PLAY_FAILED="playFailed";b.activePlugin=null;b.muted=false;b.pluginsRegistered=false;b.masterVolume=1;b.instances=[];b.instanceHash=
+{};b.idHash=null;b.defaultSoundInstance=null;b.getPreloadHandlers=function(){return{callback:b.proxy(b.initLoad,b),types:["sound"],extensions:"mp3,m4a,mp4,mpeg,ogg,wav".split(",")}};b.registerPlugins=function(a){b.pluginsRegistered=true;for(var g=0,c=a.length;g<c;g++){var d=a[g];if(d!=null&&d.isSupported())return b.activePlugin=new d,true}return false};b.registerPlugin=function(a){b.pluginsRegistered=true;if(a==null)return false;return a.isSupported()?(b.activePlugin=new a,true):false};b.isReady=
+function(){return b.activePlugin!=null};b.getCapabilities=function(){return b.activePlugin==null?null:b.activePlugin.capabilities};b.getCapability=function(a){return b.activePlugin==null?null:b.activePlugin.capabilities[a]};b.initLoad=function(a,g,c,d){if(!b.checkPlugin(true))return false;a=b.parsePath(a,g,c,d);if(a==null)return false;if(c!=null){if(b.idHash==null)b.idHash={};b.idHash[c]=a.src}c=1;d!=null&&(isNaN(d.channels)?isNaN(d)||(c=parseInt(d)):c=parseInt(d.channels));f.create(a.src,c);d=b.activePlugin.register(a.src,
+c);if(d!=null){if(d.tag!=null)a.tag=d.tag;else if(d.src)a.src=d.src;if(d.completeHandler!=null)a.handler=d.completeHandler}return a};b.parsePath=function(a,g,c,d){for(var a=a.split(b.DELIMITER),g={type:g||"sound",id:c,data:d,handler:b.handleSoundReady},c=false,d=b.getCapabilities(),h=0,e=a.length;h<e;h++){var f=a[h],i=f.lastIndexOf("."),k=f.substr(i+1).toLowerCase(),i=f.substr(0,i).split("/").pop();switch(k){case "mp3":d.mp3&&(c=true);break;case "m4a":d.mp4&&(c=true);break;case "mpeg":d.mpeg&&(c=
+true);break;case "ogg":d.ogg&&(c=true);break;case "wav":d.wav&&(c=true)}if(c)return g.name=i,g.src=f,g.extension=k,g}return null};b.play=function(a,g,c,d,h,f,e){if(!b.checkPlugin(true))return b.defaultSoundInstance;a=b.getSrcFromId(a);a=b.activePlugin.create(a);try{a.mute(b.muted)}catch(i){}b.playInstance(a,g,c,d,h,f,e)||a.playFailed();return a};b.playInstance=function(a,g,c,d,h,f,e){g=g||b.INTERRUPT_NONE;c==null&&(c=0);d==null&&(d=0);h==null&&(h=0);f==null&&(f=1);e==null&&(e=0);if(c==0){if(!b.beginPlaying(a,
+g,d,h,f,e))return false}else setTimeout(function(){b.beginPlaying(a,g,d,h,f,e)},c);this.instances.push(a);this.instanceHash[a.uniqueId]=a;return true};b.beginPlaying=function(a,b,c,d,e,j){if(!f.add(a,b))return false;return!a.beginPlaying(c,d,e,j)?(b=this.instances.indexOf(a),b>-1&&this.instances.splice(b,1),delete this.instanceHash[a.uniqueId],false):true};b.checkPlugin=function(a){return b.activePlugin==null&&(a&&!b.pluginsRegistered&&b.registerPlugin(createjs.HTMLAudioPlugin),b.activePlugin==null)?
+false:true};b.getSrcFromId=function(a){return b.idHash==null||b.idHash[a]==null?a:b.idHash[a]};b.setVolume=function(a,g){if(Number(a)==null)return false;a=Math.max(0,Math.min(1,a));return b.tellAllInstances("setVolume",g,a)};b.getMasterVolume=function(){return b.masterVolume};b.setMasterVolume=function(a){b.masterVolume=a;return b.tellAllInstances("setMasterVolume",null,a)};b.setMute=function(a){this.muted=a;return b.tellAllInstances("mute",null,a)};b.pause=function(a){return b.tellAllInstances("pause",
+a)};b.resume=function(a){return b.tellAllInstances("resume",a)};b.stop=function(a){return b.tellAllInstances("stop",a)};b.getInstanceById=function(a){return this.instanceHash[a]};b.playFinished=function(a){f.remove(a);a=this.instances.indexOf(a);a>-1&&this.instances.splice(a,1)};b.tellAllInstances=function(a,b,c){if(this.activePlugin==null)return false;for(var b=this.getSrcFromId(b),d=this.instances.length-1;d>=0;d--){var e=this.instances[d];if(!(b!=null&&e.src!=b))switch(a){case "pause":e.pause();
+break;case "resume":e.resume();break;case "setVolume":e.setVolume(c);break;case "setMasterVolume":e.setMasterVolume(c);break;case "mute":e.mute(c);break;case "stop":e.stop();break;case "setPan":e.setPan(c)}}return true};b.proxy=function(a,b){return function(){return a.apply(b,arguments)}};createjs.SoundJS=b;f.channels={};f.create=function(a,b){var c=f.get(a);c==null?f.channels[a]=new f(a,b):c.max+=b};f.add=function(a,b){var c=f.get(a.src);return c==null?false:c.add(a,b)};f.remove=function(a){var b=
+f.get(a.src);if(b==null)return false;b.remove(a);return true};f.get=function(a){return f.channels[a]};f.prototype={src:null,max:null,length:0,init:function(a,b){this.src=a;this.max=b||1;this.instances=[]},get:function(a){return this.instances[a]},add:function(a,b){if(!this.getSlot(b,a))return false;this.instances.push(a);this.length++;return true},remove:function(a){a=this.instances.indexOf(a);if(a==-1)return false;this.instances.splice(a,1);this.length--;return true},getSlot:function(a){for(var g,
+c,d=0,e=this.max||100;d<e;d++){g=this.get(d);if(g==null)return true;else if(a==b.INTERRUPT_NONE&&g.playState!=b.PLAY_FINISHED)continue;if(d==0)c=g;else if(g.playState==b.PLAY_FINISHED||g==b.PLAY_INTERRUPTED||g==b.PLAY_FAILED)c=g;else if(a==b.INTERRUPT_EARLY&&g.getPosition()<c.getPosition()||a==b.INTERRUPT_LATE&&g.getPosition()>c.getPosition())c=g}return c!=null?(c.interrupt(),this.remove(c),true):false},toString:function(){return"[SoundJS SoundChannel]"}};b.defaultSoundInstance=new function(){this.isDefault=
+true;this.pause=this.resume=this.play=this.beginPlaying=this.cleanUp=this.interrupt=this.stop=this.setMasterVolume=this.setVolume=this.mute=this.setPan=this.getPosition=this.setPosition=this.playFailed=function(){return false};this.getVolume=this.getPan=this.getDuration=function(){return 0};this.playState=b.PLAY_FAILED;this.toString=function(){return"[SoundJS Default Sound Instance]"}};e.init=function(){var a=navigator.userAgent;e.isFirefox=a.indexOf("Firefox")>-1;e.isOpera=window.opera!=null;e.isIOS=
+a.indexOf("iPod")>-1||a.indexOf("iPhone")>-1||a.indexOf("iPad")>-1};e.init();createjs.SoundJS.BrowserDetect=e})();this.createjs=this.createjs||{};
+(function(){function b(){this.init()}function f(a){this.init(a)}function e(a){this.init(a)}b.MAX_INSTANCES=30;b.capabilities=null;b.tagVolume=null;b.lastId=0;b.AUDIO_READY="canplaythrough";b.AUDIO_ENDED="ended";b.AUDIO_ERROR="error";b.AUDIO_STALLED="stalled";b.fillChannels=false;b.isSupported=function(){if(createjs.SoundJS.BrowserDetect.isIOS)return false;b.generateCapabilities();return b.tag==null?false:true};b.generateCapabilities=function(){if(b.capabilities==null){var a=b.tag=document.createElement("audio");
+if(a.canPlayType==null)return null;b.capabilities={panning:false,volume:true,mp3:a.canPlayType("audio/mp3")!="no"&&a.canPlayType("audio/mp3")!="",ogg:a.canPlayType("audio/ogg")!="no"&&a.canPlayType("audio/ogg")!="",mpeg:a.canPlayType("audio/mpeg")!="no"&&a.canPlayType("audio/mpeg")!="",wav:a.canPlayType("audio/wav")!="no"&&a.canPlayType("audio/wav")!="",mp4:a.canPlayType("audio/mp4")!="no"&&a.canPlayType("audio/mp4")!="",channels:b.MAX_INSTANCES}}};b.prototype={capabilities:null,FT:0.0010,channels:null,
+init:function(){this.capabilities=b.capabilities;this.channels={}},register:function(a,b){for(var c=e.get(a),d,f=0,j=b||1;f<j;f++)d=this.createTag(a),c.add(d);return{tag:d}},createTag:function(a){var b=document.createElement("audio");b.preload=false;b.src=a;return b},create:function(a){a=new f(a);a.owner=this;return a},toString:function(){return"[HTMLAudioPlugin]"}};createjs.HTMLAudioPlugin=b;f.prototype={src:null,uniqueId:-1,playState:null,owner:null,loaded:false,lastInterrupt:createjs.SoundJS.INTERRUPT_NONE,
+offset:0,delay:0,volume:1,pan:0,remainingLoops:0,delayTimeout:-1,tag:null,muted:false,paused:false,onComplete:null,onLoop:null,onReady:null,onPlayFailed:null,onPlayInterrupted:null,endedHandler:null,readyHandler:null,stalledHandler:null,init:function(a){this.uniqueId=createjs.HTMLAudioPlugin.lastId++;this.src=a;this.endedHandler=createjs.SoundJS.proxy(this.handleSoundComplete,this);this.readyHandler=createjs.SoundJS.proxy(this.handleSoundReady,this);this.stalledHandler=createjs.SoundJS.proxy(this.handleSoundStalled,
+this)},cleanUp:function(){var a=this.tag;if(a!=null){a.pause();try{a.currentTime=0}catch(b){}a.removeEventListener(createjs.HTMLAudioPlugin.AUDIO_ENDED,this.endedHandler,false);a.removeEventListener(createjs.HTMLAudioPlugin.AUDIO_READY,this.readyHandler,false);e.setInstance(this.src,a);this.tag=null}window.createjs!=null&&createjs.SoundJS.playFinished(this)},interrupt:function(){if(this.tag!=null){this.playState=createjs.SoundJS.PLAY_INTERRUPTED;if(this.onPlayInterrupted)this.onPlayInterrupted(this);
+this.cleanUp();this.paused=false}},play:function(a,b,c,d,e,f){this.cleanUp();createjs.SoundJS.playInstance(this,a,b,c,d,e,f)},beginPlaying:function(a,b,c){if(window.createjs!=null){var d=this.tag=e.getInstance(this.src);if(d==null)return this.playFailed(),-1;d.addEventListener(createjs.HTMLAudioPlugin.AUDIO_ENDED,this.endedHandler,false);this.offset=a;this.volume=c;this.updateVolume();this.remainingLoops=b;d.readyState!==4?(d.addEventListener(createjs.HTMLAudioPlugin.AUDIO_READY,this.readyHandler,
+false),d.addEventListener(createjs.HTMLAudioPlugin.AUDIO_STALLED,this.stalledHandler,false),d.load()):this.handleSoundReady(null);return 1}},handleSoundStalled:function(){if(this.onPlayFailed!=null)this.onPlayFailed(this)},handleSoundReady:function(){if(window.createjs!=null)if(this.playState=createjs.SoundJS.PLAY_SUCCEEDED,this.paused=false,this.tag.removeEventListener(createjs.HTMLAudioPlugin.AUDIO_READY,this.readyHandler,false),this.offset>=this.getDuration())this.playFailed();else{if(this.offset>
+0)this.tag.currentTime=this.offset*0.0010;if(this.remainingLoops==-1)this.tag.loop=true;this.tag.play()}},pause:function(){this.paused=true;return this.tag!=null?(this.tag.pause(),false):true},resume:function(){this.paused=false;return this.tag!=null?(this.tag.play(),false):true},stop:function(){this.pause();this.playState=createjs.SoundJS.PLAY_FINISHED;this.cleanUp();return true},setMasterVolume:function(){this.updateVolume();return true},setVolume:function(a){this.volume=a;this.updateVolume();return true},
+updateVolume:function(){if(this.tag!=null){var a=this.muted?0:this.volume*createjs.SoundJS.masterVolume;if(a!=this.tagVolume)this.tagVolume=this.tag.volume=a;return true}else return false},getVolume:function(){return this.volume},mute:function(a){this.muted=a;this.updateVolume();return true},setPan:function(){return false},getPan:function(){return 0},getPosition:function(){return this.tag==null?0:this.tag.currentTime*1E3},setPosition:function(a){if(this.tag==null)return false;try{this.tag.currentTime=
+a*0.0010}catch(b){return false}return true},getDuration:function(){return this.tag==null?0:this.tag.duration*1E3},handleSoundComplete:function(){if(this.remainingLoops!=0){if(this.remainingLoops--,this.tag.play(),this.onLoop!=null)this.onLoop(this)}else if(window.createjs!=null){this.playState=createjs.SoundJS.PLAY_FINISHED;if(this.onComplete!=null)this.onComplete(this);this.cleanUp()}},playFailed:function(){if(window.createjs!=null){this.playState=createjs.SoundJS.PLAY_FAILED;if(this.onPlayFailed!=
+null)this.onPlayFailed(this);this.cleanUp()}},toString:function(){return"[HTMLAudioPlugin SoundInstance]"}};e.channels={};e.get=function(a){var b=e.channels[a];b==null&&(b=e.channels[a]=new e(a));return b};e.getInstance=function(a){a=e.channels[a];return a==null?null:a.get()};e.setInstance=function(a,b){var c=e.channels[a];return c==null?null:c.set(b)};e.prototype={src:null,length:0,available:0,tags:null,init:function(a){this.src=a;this.tags=[]},add:function(a){this.tags.push(a);this.length++;this.available=
+this.tags.length},get:function(){if(this.tags.length==0)return null;this.available=this.tags.length;var a=this.tags.pop();a.parentNode==null&&document.body.appendChild(a);return a},set:function(a){this.tags.indexOf(a)==-1&&this.tags.push(a);this.available=this.tags.length},toString:function(){return"[HTMLAudioPlugin TagChannel]"}}})();
View
73 lib/soundjs.flashplugin-0.3.0.min.js
@@ -1,43 +1,30 @@
-/**
-* SoundJS FlashPlugin
-* Visit http://createjs.com/ for documentation, updates and examples.
-*
-* Contains SWFObject (http://code.google.com/p/swfobject/)
-*
-* Copyright (c) 2011 gskinner.com, inc.
-*
-* Distributed under the terms of the MIT license.
-* http://www.opensource.org/licenses/mit-license.html
-*
-* This notice shall be included in all copies or substantial portions of the Software.
-**/
-var swfobject=function(){function g(){if(!w){try{var b=e.getElementsByTagName("body")[0].appendChild(e.createElement("span"));b.parentNode.removeChild(b)}catch(c){return}w=!0;for(var b=C.length,h=0;h<b;h++)C[h]()}}function u(b){w?b():C[C.length]=b}function z(b){if(typeof o.addEventListener!=k)o.addEventListener("load",b,!1);else if(typeof e.addEventListener!=k)e.addEventListener("load",b,!1);else if(typeof o.attachEvent!=k)T(o,"onload",b);else if(typeof o.onload=="function"){var c=o.onload;o.onload=
-function(){c();b()}}else o.onload=b}function a(){var b=e.getElementsByTagName("body")[0],c=e.createElement(v);c.setAttribute("type",D);var h=b.appendChild(c);if(h){var a=0;(function(){if(typeof h.GetVariable!=k){var i=h.GetVariable("$version");if(i)i=i.split(" ")[1].split(","),f.pv=[parseInt(i[0],10),parseInt(i[1],10),parseInt(i[2],10)]}else if(a<10){a++;setTimeout(arguments.callee,10);return}b.removeChild(c);h=null;d()})()}else d()}function d(){var b=r.length;if(b>0)for(var c=0;c<b;c++){var h=r[c].id,
-a=r[c].callbackFn,i={success:!1,id:h};if(f.pv[0]>0){var e=p(h);if(e)if(E(r[c].swfVersion)&&!(f.wk&&f.wk<312)){if(x(h,!0),a)i.success=!0,i.ref=m(h),a(i)}else if(r[c].expressInstall&&q()){i={};i.data=r[c].expressInstall;i.width=e.getAttribute("width")||"0";i.height=e.getAttribute("height")||"0";if(e.getAttribute("class"))i.styleclass=e.getAttribute("class");if(e.getAttribute("align"))i.align=e.getAttribute("align");for(var j={},e=e.getElementsByTagName("param"),d=e.length,l=0;l<d;l++)e[l].getAttribute("name").toLowerCase()!=
-"movie"&&(j[e[l].getAttribute("name")]=e[l].getAttribute("value"));s(i,j,h,a)}else A(e),a&&a(i)}else if(x(h,!0),a){if((h=m(h))&&typeof h.SetVariable!=k)i.success=!0,i.ref=h;a(i)}}}function m(b){var c=null;if((b=p(b))&&b.nodeName=="OBJECT")typeof b.SetVariable!=k?c=b:(b=b.getElementsByTagName(v)[0])&&(c=b);return c}function q(){return!F&&E("6.0.65")&&(f.win||f.mac)&&!(f.wk&&f.wk<312)}function s(b,c,h,a){F=!0;I=a||null;M={success:!1,id:h};var i=p(h);if(i){i.nodeName=="OBJECT"?(B=J(i),G=null):(B=i,G=
-h);b.id=N;if(typeof b.width==k||!/%$/.test(b.width)&&parseInt(b.width,10)<310)b.width="310";if(typeof b.height==k||!/%$/.test(b.height)&&parseInt(b.height,10)<137)b.height="137";e.title=e.title.slice(0,47)+" - Flash Player Installation";a=f.ie&&f.win?"ActiveX":"PlugIn";a="MMredirectURL="+encodeURI(window.location).toString().replace(/&/g,"%26")+"&MMplayerType="+a+"&MMdoctitle="+e.title;typeof c.flashvars!=k?c.flashvars+="&"+a:c.flashvars=a;if(f.ie&&f.win&&i.readyState!=4)a=e.createElement("div"),
-h+="SWFObjectNew",a.setAttribute("id",h),i.parentNode.insertBefore(a,i),i.style.display="none",function(){i.readyState==4?i.parentNode.removeChild(i):setTimeout(arguments.callee,10)}();K(b,c,h)}}function A(b){if(f.ie&&f.win&&b.readyState!=4){var c=e.createElement("div");b.parentNode.insertBefore(c,b);c.parentNode.replaceChild(J(b),c);b.style.display="none";(function(){b.readyState==4?b.parentNode.removeChild(b):setTimeout(arguments.callee,10)})()}else b.parentNode.replaceChild(J(b),b)}function J(b){var c=
-e.createElement("div");if(f.win&&f.ie)c.innerHTML=b.innerHTML;else if(b=b.getElementsByTagName(v)[0])if(b=b.childNodes)for(var a=b.length,d=0;d<a;d++)!(b[d].nodeType==1&&b[d].nodeName=="PARAM")&&b[d].nodeType!=8&&c.appendChild(b[d].cloneNode(!0));return c}function K(b,c,a){var d,i=p(a);if(f.wk&&f.wk<312)return d;if(i){if(typeof b.id==k)b.id=a;if(f.ie&&f.win){var m="",j;for(j in b)if(b[j]!=Object.prototype[j])j.toLowerCase()=="data"?c.movie=b[j]:j.toLowerCase()=="styleclass"?m+=' class="'+b[j]+'"':
-j.toLowerCase()!="classid"&&(m+=" "+j+'="'+b[j]+'"');j="";for(var g in c)c[g]!=Object.prototype[g]&&(j+='<param name="'+g+'" value="'+c[g]+'" />');i.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+m+">"+j+"</object>";H[H.length]=b.id;d=p(b.id)}else{g=e.createElement(v);g.setAttribute("type",D);for(var l in b)b[l]!=Object.prototype[l]&&(l.toLowerCase()=="styleclass"?g.setAttribute("class",b[l]):l.toLowerCase()!="classid"&&g.setAttribute(l,b[l]));for(m in c)c[m]!=Object.prototype[m]&&
-m.toLowerCase()!="movie"&&(b=g,j=m,l=c[m],a=e.createElement("param"),a.setAttribute("name",j),a.setAttribute("value",l),b.appendChild(a));i.parentNode.replaceChild(g,i);d=g}}return d}function O(b){var c=p(b);if(c&&c.nodeName=="OBJECT")f.ie&&f.win?(c.style.display="none",function(){if(c.readyState==4){var a=p(b);if(a){for(var e in a)typeof a[e]=="function"&&(a[e]=null);a.parentNode.removeChild(a)}}else setTimeout(arguments.callee,10)}()):c.parentNode.removeChild(c)}function p(b){var c=null;try{c=e.getElementById(b)}catch(a){}return c}
-function T(b,c,a){b.attachEvent(c,a);y[y.length]=[b,c,a]}function E(b){var a=f.pv,b=b.split(".");b[0]=parseInt(b[0],10);b[1]=parseInt(b[1],10)||0;b[2]=parseInt(b[2],10)||0;return a[0]>b[0]||a[0]==b[0]&&a[1]>b[1]||a[0]==b[0]&&a[1]==b[1]&&a[2]>=b[2]?!0:!1}function P(b,a,h,d){if(!f.ie||!f.mac){var i=e.getElementsByTagName("head")[0];if(i){h=h&&typeof h=="string"?h:"screen";d&&(L=n=null);if(!n||L!=h)d=e.createElement("style"),d.setAttribute("type","text/css"),d.setAttribute("media",h),n=i.appendChild(d),
-f.ie&&f.win&&typeof e.styleSheets!=k&&e.styleSheets.length>0&&(n=e.styleSheets[e.styleSheets.length-1]),L=h;f.ie&&f.win?n&&typeof n.addRule==v&&n.addRule(b,a):n&&typeof e.createTextNode!=k&&n.appendChild(e.createTextNode(b+" {"+a+"}"))}}}function x(b,a){if(Q){var h=a?"visible":"hidden";w&&p(b)?p(b).style.visibility=h:P("#"+b,"visibility:"+h)}}function R(b){return/[\\\"<>\.;]/.exec(b)!=null&&typeof encodeURIComponent!=k?encodeURIComponent(b):b}var k="undefined",v="object",D="application/x-shockwave-flash",
-N="SWFObjectExprInst",o=window,e=document,t=navigator,S=!1,C=[function(){S?a():d()}],r=[],H=[],y=[],B,G,I,M,w=!1,F=!1,n,L,Q=!0,f=function(){var b=typeof e.getElementById!=k&&typeof e.getElementsByTagName!=k&&typeof e.createElement!=k,a=t.userAgent.toLowerCase(),h=t.platform.toLowerCase(),d=h?/win/.test(h):/win/.test(a),h=h?/mac/.test(h):/mac/.test(a),a=/webkit/.test(a)?parseFloat(a.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,i=!+"\u000b1",f=[0,0,0],j=null;if(typeof t.plugins!=k&&typeof t.plugins["Shockwave Flash"]==
-v){if((j=t.plugins["Shockwave Flash"].description)&&!(typeof t.mimeTypes!=k&&t.mimeTypes[D]&&!t.mimeTypes[D].enabledPlugin))S=!0,i=!1,j=j.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),f[0]=parseInt(j.replace(/^(.*)\..*$/,"$1"),10),f[1]=parseInt(j.replace(/^.*\.(.*)\s.*$/,"$1"),10),f[2]=/[a-zA-Z]/.test(j)?parseInt(j.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}else if(typeof o.ActiveXObject!=k)try{var g=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(g&&(j=g.GetVariable("$version")))i=!0,j=j.split(" ")[1].split(","),
-f=[parseInt(j[0],10),parseInt(j[1],10),parseInt(j[2],10)]}catch(m){}return{w3:b,pv:f,wk:a,ie:i,win:d,mac:h}}();(function(){f.w3&&((typeof e.readyState!=k&&e.readyState=="complete"||typeof e.readyState==k&&(e.getElementsByTagName("body")[0]||e.body))&&g(),w||(typeof e.addEventListener!=k&&e.addEventListener("DOMContentLoaded",g,!1),f.ie&&f.win&&(e.attachEvent("onreadystatechange",function(){e.readyState=="complete"&&(e.detachEvent("onreadystatechange",arguments.callee),g())}),o==top&&function(){if(!w){try{e.documentElement.doScroll("left")}catch(b){setTimeout(arguments.callee,
-0);return}g()}}()),f.wk&&function(){w||(/loaded|complete/.test(e.readyState)?g():setTimeout(arguments.callee,0))}(),z(g)))})();(function(){f.ie&&f.win&&window.attachEvent("onunload",function(){for(var b=y.length,a=0;a<b;a++)y[a][0].detachEvent(y[a][1],y[a][2]);b=H.length;for(a=0;a<b;a++)O(H[a]);for(var h in f)f[h]=null;f=null;for(var e in swfobject)swfobject[e]=null;swfobject=null})})();return{registerObject:function(b,a,h,e){if(f.w3&&b&&a){var d={};d.id=b;d.swfVersion=a;d.expressInstall=h;d.callbackFn=
-e;r[r.length]=d;x(b,!1)}else e&&e({success:!1,id:b})},getObjectById:function(a){if(f.w3)return m(a)},embedSWF:function(a,c,h,e,d,g,j,m,l,o){var p={success:!1,id:c};f.w3&&!(f.wk&&f.wk<312)&&a&&c&&h&&e&&d?(x(c,!1),u(function(){h+="";e+="";var f={};if(l&&typeof l===v)for(var n in l)f[n]=l[n];f.data=a;f.width=h;f.height=e;n={};if(m&&typeof m===v)for(var r in m)n[r]=m[r];if(j&&typeof j===v)for(var t in j)typeof n.flashvars!=k?n.flashvars+="&"+t+"="+j[t]:n.flashvars=t+"="+j[t];if(E(d))r=K(f,n,c),f.id==
-c&&x(c,!0),p.success=!0,p.ref=r;else if(g&&q()){f.data=g;s(f,n,c,o);return}else x(c,!0);o&&o(p)})):o&&o(p)},switchOffAutoHideShow:function(){Q=!1},ua:f,getFlashPlayerVersion:function(){return{major:f.pv[0],minor:f.pv[1],release:f.pv[2]}},hasFlashPlayerVersion:E,createSWF:function(a,c,e){if(f.w3)return K(a,c,e)},showExpressInstall:function(a,c,e,d){f.w3&&q()&&s(a,c,e,d)},removeSWF:function(a){f.w3&&O(a)},createCSS:function(a,c,e,d){f.w3&&P(a,c,e,d)},addDomLoadEvent:u,addLoadEvent:z,getQueryParamValue:function(a){var c=
-e.location.search||e.location.hash;if(c){/\?/.test(c)&&(c=c.split("?")[1]);if(a==null)return R(c);for(var c=c.split("&"),d=0;d<c.length;d++)if(c[d].substring(0,c[d].indexOf("="))==a)return R(c[d].substring(c[d].indexOf("=")+1))}return""},expressInstallCallback:function(){if(F){var a=p(N);if(a&&B){a.parentNode.replaceChild(B,a);if(G&&(x(G,!0),f.ie&&f.win))B.style.display="block";I&&I(M)}F=!1}}}}();this.createjs=this.createjs||{};
-(function(){function g(){this.init()}function u(a,d){this.init(a,d)}function z(a,d){this.init(a,d)}g.capabilities=null;g.BASE_PATH="src/soundjs/";g.lastId=0;g.isSupported=function(){if(createjs.SoundJS.BrowserDetect.isIOS)return!1;g.generateCapabilities();return swfobject==null?!1:swfobject.hasFlashPlayerVersion("9.0.0")};g.generateCapabilities=function(){if(g.capabilities==null)g.capabilities={panning:!0,volume:!0,mp3:!0,ogg:!1,mpeg:!0,wav:!0,channels:255}};g.prototype={CONTAINER_ID:"flashAudioContainer",
-capabilities:null,container:null,flash:null,flashReady:!1,flashInstances:null,flashPreloadInstances:null,queuedInstances:null,showOutput:!1,init:function(){this.capabilities=g.capabilities;this.flashInstances={};this.flashPreloadInstances={};this.queuedInstances=[];var a=this.container=document.createElement("div");a.id=this.CONTAINER_ID;a.appendChild(document.createTextNode("Default Content Here"));document.body.appendChild(a);swfobject.embedSWF(g.BASE_PATH+"FlashAudioPlugin.swf",this.CONTAINER_ID,
-"1","1","9.0.0",null,null,null,null,createjs.SoundJS.proxy(this.handleSWFReady,this))},handleSWFReady:function(a){this.flash=a.ref;this.loadTimeout=setTimeout(function(){createjs.SoundJS.proxy(this.handleTimeout,this)},2E3)},handleFlashReady:function(){this.flashReady=!0;for(var a=0,d=this.queuedInstances.length;a<d;a++)this.flash.register(this.queuedInstances[a]);this.queuedInstances=null;for(var g in this.flashPreloadInstances)this.flashPreloadInstances[g].initialize(this.flash);for(g in this.flashInstances)this.flashInstances[g].initialize(this.flash)},
-handleTimeout:function(){},register:function(a){this.flashReady?this.flash.register(a):this.queuedInstances.push(a);a=new z(a,this.flash);a.owner=this;return{tag:a}},create:function(a){try{var d=new u(a,this.flash);d.owner=this;return d}catch(g){}return null},registerPreloadInstance:function(a,d){this.flashPreloadInstances[a]=d},unregisterPreloadInstance:function(a){delete this.flashPreloadInstances[a]},registerSoundInstance:function(a,d){this.flashInstances[a]=d},unregisterSoundInstance:function(a){delete this.flashInstances[a]},
-flashLog:function(a){this.showOutput&&console.log(a)},handleSoundEvent:function(a,d){var g=this.flashInstances[a];if(g!=null){for(var q=[],s=2,A=arguments.length;s<A;s++)q.push(arguments[s]);try{if(q.length==0)g[d]();else g[d].apply(g,q)}catch(u){}}},handlePreloadEvent:function(a,d){var g=this.flashPreloadInstances[a];if(g!=null){for(var q=[],s=2,A=arguments.length;s<A;s++)q.push(arguments[s]);try{if(q.length==0)g[d]();else g[d].apply(g,q)}catch(u){}}},handleEvent:function(a){switch(a){case "ready":clearTimeout(this.loadTimeout),
-this.handleFlashReady()}},handleErrorEvent:function(){},toString:function(){return"[FlashPlugin]"}};createjs.FlashPlugin=g;u.prototype={src:null,uniqueId:-1,capabilities:null,flash:null,flashId:null,loop:0,volume:1,pan:0,muted:!1,paused:!1,onComplete:null,onLoop:null,onReady:null,onPlayFailed:null,onPlayInterrupted:null,init:function(a,d){this.uniqueId=g.lastId++;this.src=a;this.flash=d},initialize:function(a){this.flash=a},interrupt:function(){this.playState=createjs.SoundJS.PLAY_INTERRUPTED;if(this.onPlayInterrupted!=
-null)this.onPlayInterrupted(this);this.flash.interrupt(this.flashId);this.cleanUp()},cleanUp:function(){this.owner.unregisterSoundInstance(this.flashId);createjs.SoundJS.playFinished(this)},play:function(a,d,g,q,s,u){createjs.SoundJS.playInstance(this,a,d,g,q,s,u)},beginPlaying:function(a,d,g,q){this.loop=d;this.paused=!1;if(!this.owner.flashReady)return!1;this.flashId=this.flash.playSound(this.src,a,d,g,q);if(this.flashId==null){if(this.onPlayFailed!=null)this.onPlayFailed(this);this.cleanUp();return!1}this.playState=
-createjs.SoundJS.PLAY_SUCCEEDED;this.owner.registerSoundInstance(this.flashId,this);return!0},playFailed:function(){this.playState=createjs.SoundJS.PLAY_FAILED;if(this.onPlayFailed!=null)this.onPlayFailed(this);this.cleanUp()},pause:function(){this.paused=!0;return this.flash.pauseSound(this.flashId)},resume:function(){this.paused=!1;return this.flash.resumeSound(this.flashId)},stop:function(){this.playState=createjs.SoundJS.PLAY_FINISHED;this.paused=!1;var a=this.flash.stopSound(this.flashId);this.cleanUp();
-return a},setVolume:function(a){this.volume=a;return this.flash.setVolume(this.flashId,a)},getVolume:function(){return this.volume},mute:function(a){return(this.muted=a)?this.flash.muteSound(this.flashId):this.flash.unmuteSound(this.flashId)},getPan:function(){return this.pan},setPan:function(a){this.pan=a;return this.flash.setPan(this.flashId,a)},getPosition:function(){return this.flash.getPosition(this.flashId)},setPosition:function(a){return this.flash&&this.flash.setPosition(this.flashId,a)},
-getDuration:function(){return this.flash?0:this.flash.getDuration(this.flashId)},handleSoundFinished:function(){this.playState=createjs.SoundJS.PLAY_FINISHED;if(this.onComplete!=null)this.onComplete(this);this.cleanUp()},handleLoop:function(){if(this.onLoop!=null)this.onLoop(this)},toString:function(){return"[FlashPlugin SoundInstance]"}};z.prototype={flash:null,src:null,flashId:null,progress:-1,readyState:0,loading:!1,onload:null,onprogress:null,onError:null,init:function(a,d){this.src=a;this.flash=
-d},initialize:function(a){this.flash=a;this.loading&&this.load(this.src)},load:function(a){if(a!=null)this.src=a;if(this.flash==null)return loading=!0,!1;this.flashId=this.flash.preload(this.src);this.owner.registerPreloadInstance(this.flashId,this);return!0},handleProgress:function(a,d){this.progress=a/d;if(this.onprogress!=null)this.onprogress({loaded:a,total:d,progress:this.progress})},handleComplete:function(){this.progress=1;this.readyState=4;if(this.onload!=null)this.onload()},handleError:function(a){if(this.onerror!=
-null)this.onerror(a)},toString:function(){return"[FlashPlugin SoundLoader]"}}})();
+var swfobject=function(){function g(){if(!w){try{var b=e.getElementsByTagName("body")[0].appendChild(e.createElement("span"));b.parentNode.removeChild(b)}catch(c){return}w=!0;for(var b=C.length,h=0;h<b;h++)C[h]()}}function u(b){w?b():C[C.length]=b}function z(b){if(typeof o.addEventListener!=k)o.addEventListener("load",b,!1);else if(typeof e.addEventListener!=k)e.addEventListener("load",b,!1);else if(typeof o.attachEvent!=k)T(o,"onload",b);else if(typeof o.onload=="function"){var c=o.onload;o.onload=
+function(){c();b()}}else o.onload=b}function a(){var b=e.getElementsByTagName("body")[0],c=e.createElement(v);c.setAttribute("type",D);var h=b.appendChild(c);if(h){var a=0;(function(){if(typeof h.GetVariable!=k){var i=h.GetVariable("$version");if(i)i=i.split(" ")[1].split(","),f.pv=[parseInt(i[0],10),parseInt(i[1],10),parseInt(i[2],10)]}else if(a<10){a++;setTimeout(arguments.callee,10);return}b.removeChild(c);h=null;d()})()}else d()}function d(){var b=r.length;if(b>0)for(var c=0;c<b;c++){var h=r[c].id,
+a=r[c].callbackFn,i={success:!1,id:h};if(f.pv[0]>0){var e=p(h);if(e)if(E(r[c].swfVersion)&&!(f.wk&&f.wk<312)){if(x(h,!0),a)i.success=!0,i.ref=m(h),a(i)}else if(r[c].expressInstall&&q()){i={};i.data=r[c].expressInstall;i.width=e.getAttribute("width")||"0";i.height=e.getAttribute("height")||"0";if(e.getAttribute("class"))i.styleclass=e.getAttribute("class");if(e.getAttribute("align"))i.align=e.getAttribute("align");for(var j={},e=e.getElementsByTagName("param"),d=e.length,l=0;l<d;l++)e[l].getAttribute("name").toLowerCase()!=
+"movie"&&(j[e[l].getAttribute("name")]=e[l].getAttribute("value"));s(i,j,h,a)}else A(e),a&&a(i)}else if(x(h,!0),a){if((h=m(h))&&typeof h.SetVariable!=k)i.success=!0,i.ref=h;a(i)}}}function m(b){var c=null;if((b=p(b))&&b.nodeName=="OBJECT")typeof b.SetVariable!=k?c=b:(b=b.getElementsByTagName(v)[0])&&(c=b);return c}function q(){return!F&&E("6.0.65")&&(f.win||f.mac)&&!(f.wk&&f.wk<312)}function s(b,c,h,a){F=!0;I=a||null;M={success:!1,id:h};var i=p(h);if(i){i.nodeName=="OBJECT"?(B=J(i),G=null):(B=i,G=
+h);b.id=N;if(typeof b.width==k||!/%$/.test(b.width)&&parseInt(b.width,10)<310)b.width="310";if(typeof b.height==k||!/%$/.test(b.height)&&parseInt(b.height,10)<137)b.height="137";e.title=e.title.slice(0,47)+" - Flash Player Installation";a=f.ie&&f.win?"ActiveX":"PlugIn";a="MMredirectURL="+encodeURI(window.location).toString().replace(/&/g,"%26")+"&MMplayerType="+a+"&MMdoctitle="+e.title;typeof c.flashvars!=k?c.flashvars+="&"+a:c.flashvars=a;if(f.ie&&f.win&&i.readyState!=4)a=e.createElement("div"),
+h+="SWFObjectNew",a.setAttribute("id",h),i.parentNode.insertBefore(a,i),i.style.display="none",function(){i.readyState==4?i.parentNode.removeChild(i):setTimeout(arguments.callee,10)}();K(b,c,h)}}function A(b){if(f.ie&&f.win&&b.readyState!=4){var c=e.createElement("div");b.parentNode.insertBefore(c,b);c.parentNode.replaceChild(J(b),c);b.style.display="none";(function(){b.readyState==4?b.parentNode.removeChild(b):setTimeout(arguments.callee,10)})()}else b.parentNode.replaceChild(J(b),b)}function J(b){var c=
+e.createElement("div");if(f.win&&f.ie)c.innerHTML=b.innerHTML;else if(b=b.getElementsByTagName(v)[0])if(b=b.childNodes)for(var a=b.length,d=0;d<a;d++)!(b[d].nodeType==1&&b[d].nodeName=="PARAM")&&b[d].nodeType!=8&&c.appendChild(b[d].cloneNode(!0));return c}function K(b,c,a){var d,i=p(a);if(f.wk&&f.wk<312)return d;if(i){if(typeof b.id==k)b.id=a;if(f.ie&&f.win){var m="",j;for(j in b)if(b[j]!=Object.prototype[j])j.toLowerCase()=="data"?c.movie=b[j]:j.toLowerCase()=="styleclass"?m+=' class="'+b[j]+'"':
+j.toLowerCase()!="classid"&&(m+=" "+j+'="'+b[j]+'"');j="";for(var g in c)c[g]!=Object.prototype[g]&&(j+='<param name="'+g+'" value="'+c[g]+'" />');i.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+m+">"+j+"</object>";H[H.length]=b.id;d=p(b.id)}else{g=e.createElement(v);g.setAttribute("type",D);for(var l in b)b[l]!=Object.prototype[l]&&(l.toLowerCase()=="styleclass"?g.setAttribute("class",b[l]):l.toLowerCase()!="classid"&&g.setAttribute(l,b[l]));for(m in c)c[m]!=Object.prototype[m]&&
+m.toLowerCase()!="movie"&&(b=g,j=m,l=c[m],a=e.createElement("param"),a.setAttribute("name",j),a.setAttribute("value",l),b.appendChild(a));i.parentNode.replaceChild(g,i);d=g}}return d}function O(b){var c=p(b);if(c&&c.nodeName=="OBJECT")f.ie&&f.win?(c.style.display="none",function(){if(c.readyState==4){var a=p(b);if(a){for(var e in a)typeof a[e]=="function"&&(a[e]=null);a.parentNode.removeChild(a)}}else setTimeout(arguments.callee,10)}()):c.parentNode.removeChild(c)}function p(b){var c=null;try{c=e.getElementById(b)}catch(a){}return c}
+function T(b,c,a){b.attachEvent(c,a);y[y.length]=[b,c,a]}function E(b){var a=f.pv,b=b.split(".");b[0]=parseInt(b[0],10);b[1]=parseInt(b[1],10)||0;b[2]=parseInt(b[2],10)||0;return a[0]>b[0]||a[0]==b[0]&&a[1]>b[1]||a[0]==b[0]&&a[1]==b[1]&&a[2]>=b[2]?!0:!1}function P(b,a,h,d){if(!f.ie||!f.mac){var i=e.getElementsByTagName("head")[0];if(i){h=h&&typeof h=="string"?h:"screen";d&&(L=n=null);if(!n||L!=h)d=e.createElement("style"),d.setAttribute("type","text/css"),d.setAttribute("media",h),n=i.appendChild(d),
+f.ie&&f.win&&typeof e.styleSheets!=k&&e.styleSheets.length>0&&(n=e.styleSheets[e.styleSheets.length-1]),L=h;f.ie&&f.win?n&&typeof n.addRule==v&&n.addRule(b,a):n&&typeof e.createTextNode!=k&&n.appendChild(e.createTextNode(b+" {"+a+"}"))}}}function x(b,a){if(Q){var h=a?"visible":"hidden";w&&p(b)?p(b).style.visibility=h:P("#"+b,"visibility:"+h)}}function R(b){return/[\\\"<>\.;]/.exec(b)!=null&&typeof encodeURIComponent!=k?encodeURIComponent(b):b}var k="undefined",v="object",D="application/x-shockwave-flash",
+N="SWFObjectExprInst",o=window,e=document,t=navigator,S=!1,C=[function(){S?a():d()}],r=[],H=[],y=[],B,G,I,M,w=!1,F=!1,n,L,Q=!0,f=function(){var b=typeof e.getElementById!=k&&typeof e.getElementsByTagName!=k&&typeof e.createElement!=k,a=t.userAgent.toLowerCase(),h=t.platform.toLowerCase(),d=h?/win/.test(h):/win/.test(a),h=h?/mac/.test(h):/mac/.test(a),a=/webkit/.test(a)?parseFloat(a.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,i=!+"\u000b1",f=[0,0,0],j=null;if(typeof t.plugins!=k&&typeof t.plugins["Shockwave Flash"]==
+v){if((j=t.plugins["Shockwave Flash"].description)&&!(typeof t.mimeTypes!=k&&t.mimeTypes[D]&&!t.mimeTypes[D].enabledPlugin))S=!0,i=!1,j=j.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),f[0]=parseInt(j.replace(/^(.*)\..*$/,"$1"),10),f[1]=parseInt(j.replace(/^.*\.(.*)\s.*$/,"$1"),10),f[2]=/[a-zA-Z]/.test(j)?parseInt(j.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}else if(typeof o.ActiveXObject!=k)try{var g=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(g&&(j=g.GetVariable("$version")))i=!0,j=j.split(" ")[1].split(","),
+f=[parseInt(j[0],10),parseInt(j[1],10),parseInt(j[2],10)]}catch(m){}return{w3:b,pv:f,wk:a,ie:i,win:d,mac:h}}();(function(){f.w3&&((typeof e.readyState!=k&&e.readyState=="complete"||typeof e.readyState==k&&(e.getElementsByTagName("body")[0]||e.body))&&g(),w||(typeof e.addEventListener!=k&&e.addEventListener("DOMContentLoaded",g,!1),f.ie&&f.win&&(e.attachEvent("onreadystatechange",function(){e.readyState=="complete"&&(e.detachEvent("onreadystatechange",arguments.callee),g())}),o==top&&function(){if(!w){try{e.documentElement.doScroll("left")}catch(b){setTimeout(arguments.callee,
+0);return}g()}}()),f.wk&&function(){w||(/loaded|complete/.test(e.readyState)?g():setTimeout(arguments.callee,0))}(),z(g)))})();(function(){f.ie&&f.win&&window.attachEvent("onunload",function(){for(var b=y.length,a=0;a<b;a++)y[a][0].detachEvent(y[a][1],y[a][2]);b=H.length;for(a=0;a<b;a++)O(H[a]);for(var h in f)f[h]=null;f=null;for(var e in swfobject)swfobject[e]=null;swfobject=null})})();return{registerObject:function(b,a,h,e){if(f.w3&&b&&a){var d={};d.id=b;d.swfVersion=a;d.expressInstall=h;d.callbackFn=
+e;r[r.length]=d;x(b,!1)}else e&&e({success:!1,id:b})},getObjectById:function(a){if(f.w3)return m(a)},embedSWF:function(a,c,h,e,d,g,j,m,l,o){var p={success:!1,id:c};f.w3&&!(f.wk&&f.wk<312)&&a&&c&&h&&e&&d?(x(c,!1),u(function(){h+="";e+="";var f={};if(l&&typeof l===v)for(var n in l)f[n]=l[n];f.data=a;f.width=h;f.height=e;n={};if(m&&typeof m===v)for(var r in m)n[r]=m[r];if(j&&typeof j===v)for(var t in j)typeof n.flashvars!=k?n.flashvars+="&"+t+"="+j[t]:n.flashvars=t+"="+j[t];if(E(d))r=K(f,n,c),f.id==
+c&&x(c,!0),p.success=!0,p.ref=r;else if(g&&q()){f.data=g;s(f,n,c,o);return}else x(c,!0);o&&o(p)})):o&&o(p)},switchOffAutoHideShow:function(){Q=!1},ua:f,getFlashPlayerVersion:function(){return{major:f.pv[0],minor:f.pv[1],release:f.pv[2]}},hasFlashPlayerVersion:E,createSWF:function(a,c,e){if(f.w3)return K(a,c,e)},showExpressInstall:function(a,c,e,d){f.w3&&q()&&s(a,c,e,d)},removeSWF:function(a){f.w3&&O(a)},createCSS:function(a,c,e,d){f.w3&&P(a,c,e,d)},addDomLoadEvent:u,addLoadEvent:z,getQueryParamValue:function(a){var c=
+e.location.search||e.location.hash;if(c){/\?/.test(c)&&(c=c.split("?")[1]);if(a==null)return R(c);for(var c=c.split("&"),d=0;d<c.length;d++)if(c[d].substring(0,c[d].indexOf("="))==a)return R(c[d].substring(c[d].indexOf("=")+1))}return""},expressInstallCallback:function(){if(F){var a=p(N);if(a&&B){a.parentNode.replaceChild(B,a);if(G&&(x(G,!0),f.ie&&f.win))B.style.display="block";I&&I(M)}F=!1}}}}();this.createjs=this.createjs||{};
+(function(){function g(){this.init()}function u(a,d){this.init(a,d)}function z(a,d){this.init(a,d)}g.capabilities=null;g.BASE_PATH="src/soundjs/";g.lastId=0;g.isSupported=function(){if(createjs.SoundJS.BrowserDetect.isIOS)return!1;g.generateCapabilities();return swfobject==null?!1:swfobject.hasFlashPlayerVersion("9.0.0")};g.generateCapabilities=function(){if(g.capabilities==null)g.capabilities={panning:!0,volume:!0,mp3:!0,ogg:!1,mpeg:!0,wav:!0,channels:255}};g.prototype={CONTAINER_ID:"flashAudioContainer",
+capabilities:null,container:null,flash:null,flashReady:!1,flashInstances:null,flashPreloadInstances:null,queuedInstances:null,showOutput:!1,init:function(){this.capabilities=g.capabilities;this.flashInstances={};this.flashPreloadInstances={};this.queuedInstances=[];var a=this.container=document.createElement("div");a.id=this.CONTAINER_ID;a.appendChild(document.createTextNode("Default Content Here"));document.body.appendChild(a);swfobject.embedSWF(g.BASE_PATH+"FlashAudioPlugin.swf",this.CONTAINER_ID,
+"1","1","9.0.0",null,null,null,null,createjs.SoundJS.proxy(this.handleSWFReady,this))},handleSWFReady:function(a){this.flash=a.ref;this.loadTimeout=setTimeout(function(){createjs.SoundJS.proxy(this.handleTimeout,this)},2E3)},handleFlashReady:function(){this.flashReady=!0;for(var a=0,d=this.queuedInstances.length;a<d;a++)this.flash.register(this.queuedInstances[a]);this.queuedInstances=null;for(var g in this.flashPreloadInstances)this.flashPreloadInstances[g].initialize(this.flash);for(g in this.flashInstances)this.flashInstances[g].initialize(this.flash)},
+handleTimeout:function(){},register:function(a){this.flashReady?this.flash.register(a):this.queuedInstances.push(a);a=new z(a,this.flash);a.owner=this;return{tag:a}},create:function(a){try{var d=new u(a,this.flash);d.owner=this;return d}catch(g){}return null},registerPreloadInstance:function(a,d){this.flashPreloadInstances[a]=d},unregisterPreloadInstance:function(a){delete this.flashPreloadInstances[a]},registerSoundInstance:function(a,d){this.flashInstances[a]=d},unregisterSoundInstance:function(a){delete this.flashInstances[a]},
+flashLog:function(a){this.showOutput&&console.log(a)},handleSoundEvent:function(a,d){var g=this.flashInstances[a];if(g!=null){for(var q=[],s=2,A=arguments.length;s<A;s++)q.push(arguments[s]);try{if(q.length==0)g[d]();else g[d].apply(g,q)}catch(u){}}},handlePreloadEvent:function(a,d){var g=this.flashPreloadInstances[a];if(g!=null){for(var q=[],s=2,A=arguments.length;s<A;s++)q.push(arguments[s]);try{if(q.length==0)g[d]();else g[d].apply(g,q)}catch(u){}}},handleEvent:function(a){switch(a){case "ready":clearTimeout(this.loadTimeout),
+this.handleFlashReady()}},handleErrorEvent:function(){},toString:function(){return"[FlashPlugin]"}};createjs.FlashPlugin=g;u.prototype={src:null,uniqueId:-1,capabilities:null,flash:null,flashId:null,loop:0,volume:1,pan:0,muted:!1,paused:!1,onComplete:null,onLoop:null,onReady:null,onPlayFailed:null,onPlayInterrupted:null,init:function(a,d){this.uniqueId=g.lastId++;this.src=a;this.flash=d},initialize:function(a){this.flash=a},interrupt:function(){this.playState=createjs.SoundJS.PLAY_INTERRUPTED;if(this.onPlayInterrupted!=
+null)this.onPlayInterrupted(this);this.flash.interrupt(this.flashId);this.cleanUp()},cleanUp:function(){this.owner.unregisterSoundInstance(this.flashId);createjs.SoundJS.playFinished(this)},play:function(a,d,g,q,s,u){createjs.SoundJS.playInstance(this,a,d,g,q,s,u)},beginPlaying:function(a,d,g,q){this.loop=d;this.paused=!1;if(!this.owner.flashReady)return!1;this.flashId=this.flash.playSound(this.src,a,d,g,q);if(this.flashId==null){if(this.onPlayFailed!=null)this.onPlayFailed(this);this.cleanUp();return!1}this.muted&&
+this.mute(!0);this.playState=createjs.SoundJS.PLAY_SUCCEEDED;this.owner.registerSoundInstance(this.flashId,this);return!0},playFailed:function(){this.playState=createjs.SoundJS.PLAY_FAILED;if(this.onPlayFailed!=null)this.onPlayFailed(this);this.cleanUp()},pause:function(){this.paused=!0;return this.flash.pauseSound(this.flashId)},resume:function(){this.paused=!1;return this.flash.resumeSound(this.flashId)},stop:function(){this.playState=createjs.SoundJS.PLAY_FINISHED;this.paused=!1;var a=this.flash.stopSound(this.flashId);
+this.cleanUp();return a},setVolume:function(a){this.volume=a;return this.flash.setVolume(this.flashId,a)},getVolume:function(){return this.volume},mute:function(a){return(this.muted=a)?this.flash.muteSound(this.flashId):this.flash.unmuteSound(this.flashId)},getPan:function(){return this.pan},setPan:function(a){this.pan=a;return this.flash.setPan(this.flashId,a)},getPosition:function(){return this.flash.getPosition(this.flashId)},setPosition:function(a){return this.flash&&this.flash.setPosition(this.flashId,
+a)},getDuration:function(){return this.flash?0:this.flash.getDuration(this.flashId)},handleSoundFinished:function(){this.playState=createjs.SoundJS.PLAY_FINISHED;if(this.onComplete!=null)this.onComplete(this);this.cleanUp()},handleLoop:function(){if(this.onLoop!=null)this.onLoop(this)},toString:function(){return"[FlashPlugin SoundInstance]"}};z.prototype={flash:null,src:null,flashId:null,progress:-1,readyState:0,loading:!1,onload:null,onprogress:null,onError:null,init:function(a,d){this.src=a;this.flash=
+d},initialize:function(a){this.flash=a;this.loading&&this.load(this.src)},load:function(a){if(a!=null)this.src=a;if(this.flash==null)return loading=!0,!1;this.flashId=this.flash.preload(this.src);this.owner.registerPreloadInstance(this.flashId,this);return!0},handleProgress:function(a,d){this.progress=a/d;if(this.onprogress!=null)this.onprogress({loaded:a,total:d,progress:this.progress})},handleComplete:function(){this.progress=1;this.readyState=4;if(this.onload!=null)this.onload()},handleError:function(a){if(this.onerror!=
+null)this.onerror(a)},toString:function(){return"[FlashPlugin SoundLoader]"}}})();
View
BIN src/soundjs/FlashAudioPlugin.swf
Binary file not shown.
View
32 src/soundjs/HTMLAudioPlugin.js
@@ -38,6 +38,9 @@ this.createjs = this.createjs||{};
/**
* Play sounds using HTML <audio> tags in the browser.
+ * Note it is recommended to use WebAudioPlugin for iOS, as you can only have one <audio> tag,
+ * cannot preload or autoplay the audio, cannot cache the audio, and cannot play the audio except
+ * inside a user initiated event
* @class HTMLAudioPlugin
* @constructor
*/
@@ -65,6 +68,15 @@ this.createjs = this.createjs||{};
*/
s.capabilities = null;
+ /**
+ * The current value of the audio tag.
+ *
+ * @property tagVolume
+ * @type Number
+ * @default null
+ */
+ s.tagVolume = null;
+
s.lastId = 0;
// Event constants
@@ -84,7 +96,8 @@ this.createjs = this.createjs||{};
*/
s.isSupported = function() {
if (createjs.SoundJS.BrowserDetect.isIOS) { return false; }
-
+ // OJR let the user decide, inform them of limits in iOS.
+ // iOS can only have a single <audio> instance, cannot preload or autoplay, cannot cache sound, and can only be played in response to a user event (click)
s.generateCapabilities();
var t = s.tag;
if (t == null) { return false; }
@@ -107,6 +120,7 @@ this.createjs = this.createjs||{};
ogg: t.canPlayType("audio/ogg") != "no" && t.canPlayType("audio/ogg") != "",
mpeg: t.canPlayType("audio/mpeg") != "no" && t.canPlayType("audio/mpeg") != "",
wav:t.canPlayType("audio/wav") != "no" && t.canPlayType("audio/wav") != "",
+ mp4: t.canPlayType("audio/mp4") != "no" && t.canPlayType("audio/mp4") != "",
channels: s.MAX_INSTANCES
};
// TODO: Other props?
@@ -359,7 +373,7 @@ this.createjs = this.createjs||{};
handleSoundStalled: function(event) {
if (this.onPlayFailed != null) { this.onPlayFailed(this); }
- this.cleanUp();
+ // this.cleanUp(); // OJR let the music keep playing which is better?
},
handleSoundReady: function(event) {
@@ -369,7 +383,7 @@ this.createjs = this.createjs||{};
this.tag.removeEventListener(createjs.HTMLAudioPlugin.AUDIO_READY, this.readyHandler, false);
if(this.offset >= this.getDuration()) {
- this.playFailed();
+ this.playFailed(); // OJR: throw error?
return;
} else if (this.offset > 0) {
this.tag.currentTime = this.offset * 0.001;
@@ -439,7 +453,11 @@ this.createjs = this.createjs||{};
updateVolume: function() {
if (this.tag != null) {
- this.tag.volume = this.muted ? 0 : this.volume * createjs.SoundJS.masterVolume;
+ var newVolume = this.muted ? 0 : this.volume * createjs.SoundJS.masterVolume;
+ if (newVolume != this.tagVolume) {
+ this.tag.volume = newVolume;
+ this.tagVolume = newVolume;
+ }
return true;
} else {
return false;
@@ -503,7 +521,7 @@ this.createjs = this.createjs||{};
try {
this.tag.currentTime = value * 0.001;
} catch(error) { // Out of range
- return false;
+ return false; //OJR: throw error?
}
return true;
},
@@ -620,7 +638,7 @@ this.createjs = this.createjs||{};
if (this.tags.length == 0) { return null; }
this.available = this.tags.length;
var tag = this.tags.pop();
- document.body.appendChild(tag);
+ if (tag.parentNode == null) { document.body.appendChild(tag); }
return tag;
},
@@ -630,7 +648,7 @@ this.createjs = this.createjs||{};
this.tags.push(tag);
}
- document.body.removeChild(tag);
+ //document.body.removeChild(tag);
this.available = this.tags.length;
},
View
49 src/soundjs/SoundJS.js
@@ -184,7 +184,7 @@ this.createjs = this.createjs||{};
s.activePlugin = null;
/**
- * SoundJS is currently muted. No audio will play, unless existing instances are unmuted. This property
+ * SoundJS is currently muted. No audio will play, unless existing instances are un-muted. This property
* is read-only.
* @property muted
* @type {Boolean}
@@ -212,7 +212,7 @@ this.createjs = this.createjs||{};
return {
callback: s.proxy(s.initLoad, s),
types: ["sound"],
- extensions: ["mp3", "ogg", "wav"]
+ extensions: ["mp3", "m4a", "mp4", "mpeg", "ogg", "wav"]
}
}
@@ -302,12 +302,16 @@ this.createjs = this.createjs||{};
}
/**
- * Process manifest items from PreloadJS.
+ * Process manifest items from PreloadJS. This method is intended for usage by a plugin, and not for direct
+ * interaction. Currently there is no way to add instances to SoundJS without PreloadJS.
* @method initLoad
* @param {String | Object} value The src or object to load
* @param {String} type The optional type of object. Will likely be "sound".
* @param {String} id An optional id
- * @param {Number | String | Boolean | Object} data Optional data associated with the item
+ * @param {Number | String | Boolean | Object} data Optional data associated with the item. SoundJS uses the data
+ * parameter as the number of channels for an audio instance, however a "channels" property can be appended
+ * to the data object if it is used for other information. The audio channels will default to 1 if no value
+ * is found.
* @return {Object} An object with the modified values that were passed in.
* @private
*/
@@ -322,8 +326,14 @@ this.createjs = this.createjs||{};
s.idHash[id] = details.src;
}
- var ok = SoundChannel.create(details.src, data);
- var instance = s.activePlugin.register(details.src, data);
+ var numChannels = 1;
+ if (data != null) {
+ if (!isNaN(data.channels)) { numChannels = parseInt(data.channels); }
+ else if (!isNaN(data)) { numChannels = parseInt(data); }
+ }
+
+ var ok = SoundChannel.create(details.src, numChannels);
+ var instance = s.activePlugin.register(details.src, numChannels);
if (instance != null) {
// If the instance returns a tag, return it instead for preloading.
if (instance.tag != null) { details.tag = instance.tag; }
@@ -355,12 +365,19 @@ this.createjs = this.createjs||{};
var point = sound.lastIndexOf(".");
var ext = sound.substr(point+1).toLowerCase();
var name = sound.substr(0, point).split("/").pop();
+ // OJR: Is there a way to unstring the ext, and use it like if(c.[ext]) { found = true ;} ?? Then we can support infinite types without having to maintain this case statement
switch (ext) {
case "mp3":
if (c.mp3) { found = true; }
break;
+ case "m4a":
+ if (c.mp4) { found = true; }
+ break;
+ case "mpeg":
+ if (c.mpeg) { found = true; }
+ break;
case "ogg":
- if (c.ogg) { found = true }
+ if (c.ogg) { found = true; }
break;
case "wav":
if (c.wav) { found = true; }
@@ -430,6 +447,7 @@ this.createjs = this.createjs||{};
//Note that we can't pass arguments to proxy OR setTimeout (IE), so just wrap the function call.
setTimeout(function() {
s.beginPlaying(instance, interrupt, offset, loop, volume, pan);
+ // OJR can't we pass arguments in an array [arg1, arg2, ...] // and then parse the arguments array in the function?
}, delay); //LM: Can not stop before timeout elapses. Maybe add timeout interval to instance?
}
@@ -459,18 +477,23 @@ this.createjs = this.createjs||{};
}
/**
- * Determine if a plugin has been initialized. Optionally initialize the default plugin, which enables
+ * Determine if a plugin has been initialized. Optionally initialize one of the default plugins, which enables
* SoundJS to work without manually setting up the plugins.
* @method checkPlugin
- * @param {Boolean} initializeDefault Determines if the default plugin should be initialized if there
+ * @param {Boolean} initializeDefault Determines if one of the default plugins should be initialized if there
* is not yet a plugin when this is checked.
* @returns If a plugin is initialized. If the browser does not have the capabilities to initialize
* an available plugin, this will be false.
*/
s.checkPlugin = function(initializeDefault) {
if (s.activePlugin == null) {
if (initializeDefault && !s.pluginsRegistered) {
- s.registerPlugin(createjs.HTMLAudioPlugin);
+ s.registerPlugin(createjs.HTMLAudioPlugin); // For now.
+
+ // Prep for WebAudio default, coming soon.
+ // if (!createjs.WebAudioPlugin || !(s.registerPlugin(createjs.WebAudioPlugin))) {
+ // instantiate html audio backup.
+ // }
}
if (s.activePlugin == null) {
return false;
@@ -629,6 +652,7 @@ this.createjs = this.createjs||{};
for (var i=this.instances.length-1; i>=0; i--) {
var instance = this.instances[i];
if (src != null && instance.src != src) { continue; }
+ // OJR: Again, I think we can unstring the command and use it directly [command](value)
switch (command) {
case "pause":
instance.pause(); break;
@@ -669,6 +693,7 @@ this.createjs = this.createjs||{};
+ // OJR: Why is SoundChannel not it's own .js file?
/**
* SoundChannel manages the number of active instances
* @class SoundChannel
@@ -835,7 +860,7 @@ this.createjs = this.createjs||{};
// Available Space
if (target == null) {
return true;
- } else if (interrupt == SoundJS.INTERRUPT_NONE) {
+ } else if (interrupt == SoundJS.INTERRUPT_NONE && target.playState != SoundJS.PLAY_FINISHED) {
continue;
}
@@ -901,4 +926,4 @@ this.createjs = this.createjs||{};
createjs.SoundJS.BrowserDetect = BrowserDetect;
-}());
+}());

1 comment on commit 9384869

@fatlinesofcode

WebAudioPlugin::beginPlaying
/**/
setTimeout(createjs.SoundJS.proxy(this.handlePlaybackComplete, this), source.buffer.duration
1000);
/
**/

Really?? is this only way to fire the onComplete?

Please sign in to comment.