try catch audio
parent
dc1fdba3c3
commit
91fbb1bbab
|
@ -76,18 +76,23 @@ R3.D3.Audio.prototype.createInstance = function() {
|
||||||
if (document.documentMode || /Edge/.test(navigator.userAgent)) {
|
if (document.documentMode || /Edge/.test(navigator.userAgent)) {
|
||||||
R3.Component.prototype.createInstance.call(this);
|
R3.Component.prototype.createInstance.call(this);
|
||||||
} else {
|
} else {
|
||||||
audioLoader.load(
|
try {
|
||||||
this.apiUrl + this.path + '?ts=' + Date.now(),
|
audioLoader.load(
|
||||||
function (buffer) {
|
this.apiUrl + this.path + '?ts=' + Date.now(),
|
||||||
|
function (buffer) {
|
||||||
|
|
||||||
console.log('loaded audio: ' + this.name);
|
console.log('loaded audio: ' + this.name);
|
||||||
|
|
||||||
this.instance.setBuffer(buffer);
|
this.instance.setBuffer(buffer);
|
||||||
this.instance.setLoop(this.loop);
|
this.instance.setLoop(this.loop);
|
||||||
this.instance.setVolume(this.volume);
|
this.instance.setVolume(this.volume);
|
||||||
R3.Component.prototype.createInstance.call(this);
|
R3.Component.prototype.createInstance.call(this);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('failed to load audio - does it exist? : ' + error.message || 'unknown reason');
|
||||||
|
R3.Component.prototype.createInstance.call(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue