mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +01:00
39 lines
578 B
JavaScript
39 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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|