From e7fb268843e010e77b025fec54045fb283411482 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 15 Apr 2017 12:18:50 +1200 Subject: [PATCH] Update to use modified Recording API --- scripts/system/playRecordingAC.js | 50 ++++++++++++++++++------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/scripts/system/playRecordingAC.js b/scripts/system/playRecordingAC.js index 6043f998bd..0a47de8eff 100644 --- a/scripts/system/playRecordingAC.js +++ b/scripts/system/playRecordingAC.js @@ -21,6 +21,7 @@ HEARTBEAT_INTERVAL = 3000, // TODO: Final value. TIMESTAMP_UPDATE_INTERVAL = 2500, // TODO: Final value. AUTOPLAY_SEARCH_INTERVAL = 5000, // TODO: Final value. + AUTOPLAY_ERROR_INTERVAL = 30000, // 30s scriptUUID, Entity, @@ -262,24 +263,9 @@ // Recording playback functions. var isPlayingRecording = false, recordingFilename = "", - autoPlayTimer = null; + autoPlayTimer = null, - function playRecording(recording, position, orientation) { - Agent.isAvatar = true; - Avatar.position = position; - Avatar.orientation = orientation; - - Recording.loadRecording(recording); - Recording.setPlayFromCurrentLocation(true); - Recording.setPlayerUseDisplayName(true); - Recording.setPlayerUseHeadModel(false); - Recording.setPlayerUseAttachments(true); - Recording.setPlayerLoop(true); - Recording.setPlayerUseSkeletonModel(true); - - Recording.setPlayerTime(0.0); - Recording.startPlaying(); - } + playRecording; function play(recording, position, orientation) { if (Entity.create(recording, position, orientation)) { @@ -297,17 +283,39 @@ recording = Entity.find(); if (recording) { - isPlayingRecording = true; - recordingFilename = recording.recording; - log("Play persisted recording " + recordingFilename); - playRecording(recording.recording, recording.position, recording.orientation); } else { autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_SEARCH_INTERVAL); // Try again soon. } } + playRecording = function (recording, position, orientation) { + Recording.loadRecording(recording, function (success) { + if (success) { + Agent.isAvatar = true; + Avatar.position = position; + Avatar.orientation = orientation; + + Recording.setPlayFromCurrentLocation(true); + Recording.setPlayerUseDisplayName(true); + Recording.setPlayerUseHeadModel(false); + Recording.setPlayerUseAttachments(true); + Recording.setPlayerLoop(true); + Recording.setPlayerUseSkeletonModel(true); + + isPlayingRecording = true; + recordingFilename = recording; + + Recording.setPlayerTime(0.0); + Recording.startPlaying(); + } else { + log("Failed to load recording " + recording); + autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_ERROR_INTERVAL); // Try again later. + } + }); + }; + function stop() { log("Stop playing " + recordingFilename);