/** * @description Manages the playback of sounds. * @class SoundLibrary * @memberof jibo.sound */ /** * Sets the base path to prepend to all relative sound paths. * @name jibo.sound#basePath * @type {String} */ /** * Sets the base URL to prepend to all remote sound paths. * @name jibo.sound#baseUrl * @type {String} */ /** * The global context to use. * @name jibo.sound#_context * @type {jibo.sound.SoundContext} * @private */ /** * The map of all sounds by alias. * @name jibo.sound#_sounds * @type {Object} * @private */ /** * The global context to use. * @name jibo.sound#context * @readOnly * @type {jibo.sound.SoundContext} * @private */ /** * Adds a new sound by alias. * @method jibo.sound#add * @param {String} alias The sound alias reference. * @param {ArrayBuffer|String|Object} options Either the path or url to the source file. * or the object of options to use. * @param {ArrayBuffer|String} [options.src] If `options` is an object, the source of file. * @param {Boolean} [options.autoPlay=false] true to play after loading. * @param {Boolean} [options.preload=false] true to immediately start preloading. * @param {Boolean} [options.block=false] true to only play one instance of the sound at a time. * @param {Number} [options.volume=1] The amount of volume 1 = 100%. * @param {Boolean} [options.useXHR=false] true to use XMLHttpRequest to load the sound. Default is false, loaded with NodeJS's `fs` module. * @param {Number} [options.panning=0] The panning amount from -1 (left) to 1 (right). * @param {jibo.sound.Sound~completeCallback} [options.complete=null] Global complete callback when play is finished. * @param {jibo.sound.Sound~loadedCallback} [options.loaded=null] Call when finished loading. * @return {jibo.sound.Sound} Instance to the Sound object. */ /** * Adds multiple sounds. * @method jibo.sound#addMap * @param {Object} alias Map of sounds to add, the key is the alias, the value is the * string, ArrayBuffer or the list of options (see `add` method for options). * @param {Object|String|ArrayBuffer} globalOptions The default options for all sounds. * if a property is defined, it will use the local property instead. * @return {jibo.sound.Sound} Instance to the Sound object. */ /** * Removes a sound by alias. * @method jibo.sound#remove * @param {String} alias The sound alias reference. * @return {jibo.sound} Instance for chaining. */ /** * Pauses any playing sounds. * @method jibo.sound#pauseAll * @return {jibo.sound} Instance for chaining. */ /** * Resumes any sounds. * @method jibo.sound#resumeAll * @return {jibo.sound} Instance for chaining. */ /** * Mutes all playing sounds. * @method jibo.sound#muteAll * @return {jibo.sound} Instance for chaining. */ /** * Unmutes all playing sounds. * @method jibo.sound#unmuteAll * @return {jibo.sound} Instance for chaining. */ /** * Stops and removes all sounds. They cannot be used after this. * @method jibo.sound#removeAll * @return {jibo.sound} Instance for chaining. */ /** * Stops all sounds. * @method jibo.sound#stopAll * @return {jibo.sound} Instance for chaining. */ /** * Checks if a sound by alias exists. * @method jibo.sound#exists * @param {String} alias Check for alias. * @return {Boolean} true if the sound exists. */ /** * Gets a sound. * @method jibo.sound#sound * @param {String} alias The sound alias reference. * @return {jibo.sound.Sound|null} Sound object or `null` if it doew not exist. */ /** * Plays a sound. * @method jibo.sound#play * @param {String} alias The sound alias reference. * @param {Object|Function} options The options or callback when done. * @param {Function} [options.complete] When completed. * @param {Function} [options.loaded] If not already preloaded, callback when finishes load. * @param {Number} [options.offset=0] Start time offset. * @return {jibo.sound.SoundInstance|null} The sound instance, this cannot be reused * after it is done playing. Returns `null` if the sound has not yet loaded. */ /** * Stops a sound. * @method jibo.sound#stop * @param {String} alias The sound alias reference. * @return {jibo.sound.Sound|null} Sound object or `null` if it does not exist. */ /** * Pauses a sound. * @method jibo.sound#pause * @param {String} alias The sound alias reference. * @return {jibo.sound.Sound|null} Sound object or `null` if it does not exist. */ /** * Resumes a sound. * @method jibo.sound#resume * @param {String} alias The sound alias reference. * @return {jibo.sound.Sound|null} Instance for chaining or `null` if it does not exist. */ /** * Destroys the sound module. * @method jibo.sound#destroy * @private */