1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12:41 +01:00
phorge-phorge/webroot/rsrc/externals/javelin/lib/Sound.js
epriestley 5afa2c3b62 Add support for playing sounds
Summary:
Ref T5369. New HTML5 version without flash dependencies.

This doesn't play any sounds.

Test Plan: Did not play any sounds.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T5369

Differential Revision: https://secure.phabricator.com/D9535
2015-03-10 14:20:00 -07:00

38 lines
578 B
JavaScript

/**
* @requires javelin-install
* @provides javelin-sound
* @javelin
*/
JX.install('Sound', {
statics: {
_sounds: {},
load: function(uri) {
var self = JX.Sound;
if (!(uri in self._sounds)) {
self._sounds[uri] = JX.$N(
'audio',
{
src: uri,
preload: 'auto'
});
}
},
play: function(uri) {
var self = JX.Sound;
self.load(uri);
var sound = self._sounds[uri];
try {
sound.play();
} catch (ex) {
JX.log(ex);
}
}
}
});