2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-02-12 12:25:30 +00:00
|
|
|
var BaseSound = require('../BaseSound');
|
2018-01-20 19:56:49 +00:00
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var EventEmitter = require('eventemitter3');
|
2018-01-20 20:28:37 +00:00
|
|
|
var Extend = require('../../utils/object/Extend');
|
2018-01-26 14:39:34 +00:00
|
|
|
|
2018-02-12 12:25:30 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* No audio implementation of the sound. It is used if audio has been
|
|
|
|
* disabled in the game config or the device doesn't support any audio.
|
|
|
|
*
|
|
|
|
* It represents a graceful degradation of sound logic that provides
|
|
|
|
* minimal functionality and prevents Phaser projects that use audio from
|
|
|
|
* breaking on devices that don't support any audio playback technologies.
|
|
|
|
*
|
|
|
|
* @class NoAudioSound
|
2018-02-18 19:18:41 +00:00
|
|
|
* @extends Phaser.Sound.BaseSound
|
2018-02-12 12:25:30 +00:00
|
|
|
* @memberOf Phaser.Sound
|
|
|
|
* @constructor
|
2018-01-26 13:51:34 +00:00
|
|
|
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
|
2018-02-12 12:25:30 +00:00
|
|
|
* @since 3.0.0
|
2018-02-18 19:18:41 +00:00
|
|
|
*
|
2018-02-12 12:25:30 +00:00
|
|
|
* @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance.
|
|
|
|
* @param {string} key - Asset key for the sound.
|
2018-02-18 19:18:41 +00:00
|
|
|
* @param {SoundConfig} [config={}] - An optional config object containing default sound settings.
|
2018-01-26 13:51:34 +00:00
|
|
|
*/
|
2018-01-20 19:56:49 +00:00
|
|
|
var NoAudioSound = new Class({
|
2018-02-12 12:25:30 +00:00
|
|
|
|
2018-01-20 19:56:49 +00:00
|
|
|
Extends: EventEmitter,
|
2018-01-26 14:39:34 +00:00
|
|
|
|
2018-02-12 12:25:30 +00:00
|
|
|
initialize:
|
|
|
|
|
|
|
|
function NoAudioSound (manager, key, config)
|
2018-01-26 14:39:34 +00:00
|
|
|
{
|
2018-01-26 13:52:03 +00:00
|
|
|
if (config === void 0) { config = {}; }
|
2018-01-20 19:56:49 +00:00
|
|
|
EventEmitter.call(this);
|
2018-01-20 19:58:02 +00:00
|
|
|
this.manager = manager;
|
2018-01-20 19:58:31 +00:00
|
|
|
this.key = key;
|
2018-01-20 19:59:13 +00:00
|
|
|
this.isPlaying = false;
|
2018-01-20 19:59:27 +00:00
|
|
|
this.isPaused = false;
|
2018-01-20 20:00:31 +00:00
|
|
|
this.totalRate = 1;
|
2018-01-20 20:00:50 +00:00
|
|
|
this.duration = 0;
|
2018-01-20 20:01:04 +00:00
|
|
|
this.totalDuration = 0;
|
2018-01-20 20:07:00 +00:00
|
|
|
this.config = Extend({
|
|
|
|
mute: false,
|
|
|
|
volume: 1,
|
|
|
|
rate: 1,
|
|
|
|
detune: 0,
|
|
|
|
seek: 0,
|
|
|
|
loop: false,
|
|
|
|
delay: 0
|
|
|
|
}, config);
|
2018-01-20 20:07:30 +00:00
|
|
|
this.currentConfig = this.config;
|
2018-01-20 20:07:54 +00:00
|
|
|
this.mute = false;
|
2018-01-20 20:08:08 +00:00
|
|
|
this.volume = 1;
|
2018-01-20 20:08:21 +00:00
|
|
|
this.rate = 1;
|
2018-01-20 20:08:34 +00:00
|
|
|
this.detune = 0;
|
2018-01-20 20:08:47 +00:00
|
|
|
this.seek = 0;
|
2018-01-20 20:09:08 +00:00
|
|
|
this.loop = false;
|
2018-01-20 20:09:28 +00:00
|
|
|
this.markers = {};
|
2018-01-20 20:09:46 +00:00
|
|
|
this.currentMarker = null;
|
2018-01-20 20:10:00 +00:00
|
|
|
this.pendingRemove = false;
|
2018-01-20 20:10:51 +00:00
|
|
|
},
|
2018-02-18 19:23:31 +00:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
addMarker: function (marker)
|
2018-01-26 14:39:34 +00:00
|
|
|
{
|
2018-01-20 20:10:51 +00:00
|
|
|
return false;
|
2018-01-20 20:11:16 +00:00
|
|
|
},
|
2018-02-18 19:23:55 +00:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
updateMarker: function (marker)
|
2018-01-26 14:39:34 +00:00
|
|
|
{
|
2018-01-20 20:11:16 +00:00
|
|
|
return false;
|
2018-01-20 20:11:35 +00:00
|
|
|
},
|
2018-02-18 19:24:05 +00:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
removeMarker: function (markerName)
|
2018-01-26 14:39:34 +00:00
|
|
|
{
|
2018-01-20 20:11:35 +00:00
|
|
|
return null;
|
2018-01-20 20:11:53 +00:00
|
|
|
},
|
2018-02-18 19:24:18 +00:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
play: function (markerName, config)
|
2018-01-26 14:39:34 +00:00
|
|
|
{
|
2018-01-20 20:11:53 +00:00
|
|
|
return false;
|
2018-01-20 20:12:18 +00:00
|
|
|
},
|
2018-01-26 14:39:34 +00:00
|
|
|
pause: function ()
|
|
|
|
{
|
2018-01-20 20:12:18 +00:00
|
|
|
return false;
|
2018-01-20 20:12:36 +00:00
|
|
|
},
|
2018-01-26 14:39:34 +00:00
|
|
|
resume: function ()
|
|
|
|
{
|
2018-01-20 20:12:36 +00:00
|
|
|
return false;
|
2018-01-20 20:12:53 +00:00
|
|
|
},
|
2018-01-26 14:39:34 +00:00
|
|
|
stop: function ()
|
|
|
|
{
|
2018-01-20 20:12:53 +00:00
|
|
|
return false;
|
2018-01-20 20:13:36 +00:00
|
|
|
},
|
2018-01-26 14:39:34 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
2018-01-20 20:18:42 +00:00
|
|
|
this.manager.remove(this);
|
2018-02-12 12:25:30 +00:00
|
|
|
|
2018-01-20 20:14:15 +00:00
|
|
|
BaseSound.prototype.destroy.call(this);
|
|
|
|
}
|
2018-02-12 12:25:30 +00:00
|
|
|
|
2018-01-20 19:56:49 +00:00
|
|
|
});
|
2018-02-12 12:25:30 +00:00
|
|
|
|
2018-01-20 19:56:49 +00:00
|
|
|
module.exports = NoAudioSound;
|