phaser/src/sound/noaudio/NoAudioSound.js

111 lines
2.9 KiB
JavaScript
Raw Normal View History

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');
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
* @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.
*/
var NoAudioSound = new Class({
2018-02-12 12:25:30 +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 = {}; }
EventEmitter.call(this);
this.manager = manager;
this.key = key;
this.isPlaying = false;
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;
this.totalDuration = 0;
this.config = Extend({
mute: false,
volume: 1,
rate: 1,
detune: 0,
seek: 0,
loop: false,
delay: 0
}, config);
this.currentConfig = this.config;
this.mute = false;
this.volume = 1;
this.rate = 1;
this.detune = 0;
this.seek = 0;
this.loop = false;
this.markers = {};
this.currentMarker = null;
this.pendingRemove = false;
},
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
{
return false;
},
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
{
return false;
},
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
{
return null;
},
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
{
return false;
},
2018-01-26 14:39:34 +00:00
pause: function ()
{
return false;
},
2018-01-26 14:39:34 +00:00
resume: function ()
{
return false;
},
2018-01-26 14:39:34 +00:00
stop: function ()
{
return false;
2018-01-20 20:13:36 +00:00
},
2018-01-26 14:39:34 +00:00
destroy: function ()
{
this.manager.remove(this);
2018-02-12 12:25:30 +00:00
BaseSound.prototype.destroy.call(this);
}
2018-02-12 12:25:30 +00:00
});
2018-02-12 12:25:30 +00:00
module.exports = NoAudioSound;