From cb0b5b5d02a10ff04b5bdd53fe0bb3bf129ac17c Mon Sep 17 00:00:00 2001 From: AlessandroSigna Date: Tue, 24 Nov 2015 18:30:31 -0800 Subject: [PATCH] added prompt --- .../entityScripts/recordingEntityScript.js | 6 ++-- examples/entityScripts/recordingMaster.js | 36 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/entityScripts/recordingEntityScript.js b/examples/entityScripts/recordingEntityScript.js index 0694ff431e..dedfbf809e 100644 --- a/examples/entityScripts/recordingEntityScript.js +++ b/examples/entityScripts/recordingEntityScript.js @@ -84,7 +84,7 @@ overlay = null; }, - startRecording: function (entityID) { + startRecording: function () { if (!isAvatarRecording) { print("RECORDING STARTED"); Messages.sendMessage(CLIENTS_TO_MASTER_CHANNEL, PARTICIPATING_MESSAGE); //tell to master that I'm participating @@ -94,7 +94,7 @@ } }, - stopRecording: function (entityID) { + stopRecording: function () { if (isAvatarRecording) { print("RECORDING ENDED"); Recording.stopRecording(); @@ -109,7 +109,7 @@ _this.stopRecording(); Messages.unsubscribe(MASTER_TO_CLIENTS_CHANNEL); Messages.messageReceived.disconnect(receivingMessage); - if(overlay !== null){ + if (overlay !== null) { Overlays.deleteOverlay(overlay); overlay = null; } diff --git a/examples/entityScripts/recordingMaster.js b/examples/entityScripts/recordingMaster.js index 51149991c2..0aa3e6f866 100644 --- a/examples/entityScripts/recordingMaster.js +++ b/examples/entityScripts/recordingMaster.js @@ -29,11 +29,14 @@ var STOP_MESSAGE = "recordingEnded"; var PARTICIPATING_MESSAGE = "participatingToRecording"; var TIMEOUT = 20; + var toolBar = null; var recordIcon; var isRecording = false; var performanceJSON = { "avatarClips" : [] }; var responsesExpected = 0; +var readyToPrintInfo = false; +var performanceFileURL = null; var waitingForPerformanceFile = true; var totalWaitingTime = 0; var extension = "txt"; @@ -71,9 +74,9 @@ function mousePressEvent(event) { print("I'm the master. I want to start recording"); Messages.sendMessage(MASTER_TO_CLIENTS_CHANNEL, START_MESSAGE); isRecording = true; + waitingForPerformanceFile = true; } else { print("I want to stop recording"); - waitingForPerformanceFile = true; Script.update.connect(update); Messages.sendMessage(MASTER_TO_CLIENTS_CHANNEL, STOP_MESSAGE); isRecording = false; @@ -108,29 +111,38 @@ function update(deltaTime) { } //clean things after upload performance file to asset waitingForPerformanceFile = false; - responsesExpected = 0; totalWaitingTime = 0; Script.update.disconnect(update); - performanceJSON = { "avatarClips" : [] }; } + } else if (readyToPrintInfo == true){ + Window.prompt("Performance file and clips: ", getUtilityString()); + responsesExpected = 0; + performanceJSON = { "avatarClips" : [] }; + Script.update.disconnect(update); } } +function getUtilityString() { + var resultString = "JSON:\n" + performanceFileURL + "\n" + responsesExpected + " avatar clips:\n"; + var avatarClips = performanceJSON.avatarClips; + avatarClips.forEach(function(param) { + resultString += param + "\n"; + }); + return resultString; +} + function uploadFinished(url){ //need to print somehow the url here this way the master can copy the url - print("PERFORMANCE FILE URL: " + url); - Assets.downloadData(url, function (data) { - printPerformanceJSON(JSON.parse(data)); - }); -} - -function printPerformanceJSON(obj) { print("some info:"); - print("downloaded performance file from asset and examinating its content..."); - var avatarClips = obj.avatarClips; + performanceFileURL = url; + print("PERFORMANCE FILE URL: " + performanceFileURL); + print("number of clips obtained:" + responsesExpected); + var avatarClips = performanceJSON.avatarClips; avatarClips.forEach(function(param) { print("clip url obtained: " + param); }); + readyToPrintInfo = true; + Script.update.connect(update); } function cleanup() {