mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
cleanup
This commit is contained in:
parent
68d43dc576
commit
0b06cf1dfb
1 changed files with 8 additions and 5 deletions
|
@ -8,7 +8,6 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
var soundMap = [{
|
||||
name: 'river water',
|
||||
url: "http://hifi-public.s3.amazonaws.com/ryan/Water_Lap_River_Edge_Gentle.L.wav",
|
||||
|
@ -90,7 +89,6 @@ function loadSounds() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function playSound(soundData) {
|
||||
if (soundData.injector) {
|
||||
// try/catch in case the injector QObject has been deleted already
|
||||
|
@ -103,10 +101,12 @@ function playSound(soundData) {
|
|||
|
||||
function checkDownloaded(soundData) {
|
||||
if (soundData.sound.downloaded) {
|
||||
|
||||
Script.clearInterval(soundData.downloadTimer);
|
||||
|
||||
if (soundData.hasOwnProperty('playAtInterval')) {
|
||||
soundData.playingInterval = Script.setInterval(function() {
|
||||
playSound(soundData);
|
||||
playSound(soundData)
|
||||
}, soundData.playAtInterval);
|
||||
} else {
|
||||
playSound(soundData);
|
||||
|
@ -118,23 +118,26 @@ function checkDownloaded(soundData) {
|
|||
function startCheckDownloadedTimers() {
|
||||
soundMap.forEach(function(soundData) {
|
||||
soundData.downloadTimer = Script.setInterval(function() {
|
||||
checkDownloaded(soundData)
|
||||
checkDownloaded(soundData);
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
soundMap.forEach(function(soundData) {
|
||||
|
||||
if (soundData.hasOwnProperty("injector")) {
|
||||
soundData.injector.stop();
|
||||
}
|
||||
|
||||
if (soundData.hasOwnProperty("downloadTimer")) {
|
||||
Script.clearInterval(soundData.downloadTimer);
|
||||
|
||||
}
|
||||
|
||||
if (soundData.hasOwnProperty("playingInterval")) {
|
||||
Script.clearInterval(soundData.playingInterval);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue