mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 22:28:48 +02:00
Delete persistence entity if recording fails to load for manual playback
This commit is contained in:
parent
6d9bf2b33e
commit
4b175e98e9
1 changed files with 30 additions and 8 deletions
|
@ -48,9 +48,17 @@
|
||||||
searchState = SEARCH_IDLE,
|
searchState = SEARCH_IDLE,
|
||||||
otherPlayersPlaying,
|
otherPlayersPlaying,
|
||||||
otherPlayersPlayingCounts,
|
otherPlayersPlayingCounts,
|
||||||
pauseCount;
|
pauseCount,
|
||||||
|
isDestroyLater = false,
|
||||||
|
|
||||||
|
destroy;
|
||||||
|
|
||||||
function onUpdateTimestamp() {
|
function onUpdateTimestamp() {
|
||||||
|
if (isDestroyLater) {
|
||||||
|
destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
userData.timestamp = Date.now();
|
userData.timestamp = Date.now();
|
||||||
Entities.editEntity(entityID, { userData: JSON.stringify(userData) });
|
Entities.editEntity(entityID, { userData: JSON.stringify(userData) });
|
||||||
EntityViewer.queryOctree(); // Keep up to date ready for find().
|
EntityViewer.queryOctree(); // Keep up to date ready for find().
|
||||||
|
@ -229,7 +237,7 @@
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy() {
|
destroy = function () {
|
||||||
// Delete current persistence entity.
|
// Delete current persistence entity.
|
||||||
if (entityID !== null) { // Just in case.
|
if (entityID !== null) { // Just in case.
|
||||||
Entities.deleteEntity(entityID);
|
Entities.deleteEntity(entityID);
|
||||||
|
@ -240,6 +248,11 @@
|
||||||
Script.clearInterval(updateTimestampTimer);
|
Script.clearInterval(updateTimestampTimer);
|
||||||
updateTimestampTimer = null;
|
updateTimestampTimer = null;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function destroyLater() {
|
||||||
|
// Schedules a call to destroy() when timer threading suits.
|
||||||
|
isDestroyLater = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
@ -260,6 +273,7 @@
|
||||||
create: create,
|
create: create,
|
||||||
find: find,
|
find: find,
|
||||||
destroy: destroy,
|
destroy: destroy,
|
||||||
|
destroyLater: destroyLater,
|
||||||
setUp: setUp,
|
setUp: setUp,
|
||||||
tearDown: tearDown
|
tearDown: tearDown
|
||||||
};
|
};
|
||||||
|
@ -297,7 +311,7 @@
|
||||||
log("Play recording " + recording);
|
log("Play recording " + recording);
|
||||||
isPlayingRecording = true; // Immediate feedback.
|
isPlayingRecording = true; // Immediate feedback.
|
||||||
recordingFilename = recording;
|
recordingFilename = recording;
|
||||||
playRecording(recordingFilename, position, orientation);
|
playRecording(recordingFilename, position, orientation, true);
|
||||||
} else {
|
} else {
|
||||||
errorMessage = "Could not persist recording " + recording.slice(4); // Remove leading "atp:".
|
errorMessage = "Could not persist recording " + recording.slice(4); // Remove leading "atp:".
|
||||||
log(errorMessage);
|
log(errorMessage);
|
||||||
|
@ -317,14 +331,17 @@
|
||||||
if (recording) {
|
if (recording) {
|
||||||
log("Play persisted recording " + recording.recording);
|
log("Play persisted recording " + recording.recording);
|
||||||
userID = null;
|
userID = null;
|
||||||
playRecording(recording.recording, recording.position, recording.orientation);
|
autoPlayTimer = null;
|
||||||
|
isPlayingRecording = true; // Immediate feedback.
|
||||||
|
recordingFilename = recording.recording;
|
||||||
|
playRecording(recording.recording, recording.position, recording.orientation, false);
|
||||||
} else {
|
} else {
|
||||||
autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_SEARCH_INTERVAL); // Try again soon.
|
autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_SEARCH_INTERVAL); // Try again soon.
|
||||||
}
|
}
|
||||||
}, Math.random() * AUTOPLAY_SEARCH_DELTA);
|
}, Math.random() * AUTOPLAY_SEARCH_DELTA);
|
||||||
}
|
}
|
||||||
|
|
||||||
playRecording = function (recording, position, orientation) {
|
playRecording = function (recording, position, orientation, isManual) {
|
||||||
Recording.loadRecording(recording, function (success) {
|
Recording.loadRecording(recording, function (success) {
|
||||||
var errorMessage;
|
var errorMessage;
|
||||||
|
|
||||||
|
@ -342,17 +359,22 @@
|
||||||
Recording.setPlayerLoop(true);
|
Recording.setPlayerLoop(true);
|
||||||
Recording.setPlayerUseSkeletonModel(true);
|
Recording.setPlayerUseSkeletonModel(true);
|
||||||
|
|
||||||
isPlayingRecording = true;
|
|
||||||
recordingFilename = recording;
|
|
||||||
|
|
||||||
Recording.setPlayerTime(0.0);
|
Recording.setPlayerTime(0.0);
|
||||||
Recording.startPlaying();
|
Recording.startPlaying();
|
||||||
|
|
||||||
UserActivityLogger.logAction("playRecordingAC_play_recording");
|
UserActivityLogger.logAction("playRecordingAC_play_recording");
|
||||||
} else {
|
} else {
|
||||||
|
if (isManual) {
|
||||||
|
// Delete persistence entity if manual play request.
|
||||||
|
Entity.destroyLater(); // Schedule for deletion; works around timer threading issues.
|
||||||
|
}
|
||||||
|
|
||||||
errorMessage = "Could not load recording " + recording.slice(4); // Remove leading "atp:".
|
errorMessage = "Could not load recording " + recording.slice(4); // Remove leading "atp:".
|
||||||
log(errorMessage);
|
log(errorMessage);
|
||||||
error(errorMessage);
|
error(errorMessage);
|
||||||
|
|
||||||
|
isPlayingRecording = false;
|
||||||
|
recordingFilename = "";
|
||||||
autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_ERROR_INTERVAL); // Try again later.
|
autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_ERROR_INTERVAL); // Try again later.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue