added prompt

This commit is contained in:
AlessandroSigna 2015-11-24 18:30:31 -08:00
parent 811fa8da39
commit cb0b5b5d02
2 changed files with 27 additions and 15 deletions

View file

@ -84,7 +84,7 @@
overlay = null; overlay = null;
}, },
startRecording: function (entityID) { startRecording: function () {
if (!isAvatarRecording) { if (!isAvatarRecording) {
print("RECORDING STARTED"); print("RECORDING STARTED");
Messages.sendMessage(CLIENTS_TO_MASTER_CHANNEL, PARTICIPATING_MESSAGE); //tell to master that I'm participating 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) { if (isAvatarRecording) {
print("RECORDING ENDED"); print("RECORDING ENDED");
Recording.stopRecording(); Recording.stopRecording();
@ -109,7 +109,7 @@
_this.stopRecording(); _this.stopRecording();
Messages.unsubscribe(MASTER_TO_CLIENTS_CHANNEL); Messages.unsubscribe(MASTER_TO_CLIENTS_CHANNEL);
Messages.messageReceived.disconnect(receivingMessage); Messages.messageReceived.disconnect(receivingMessage);
if(overlay !== null){ if (overlay !== null) {
Overlays.deleteOverlay(overlay); Overlays.deleteOverlay(overlay);
overlay = null; overlay = null;
} }

View file

@ -29,11 +29,14 @@ var STOP_MESSAGE = "recordingEnded";
var PARTICIPATING_MESSAGE = "participatingToRecording"; var PARTICIPATING_MESSAGE = "participatingToRecording";
var TIMEOUT = 20; var TIMEOUT = 20;
var toolBar = null; var toolBar = null;
var recordIcon; var recordIcon;
var isRecording = false; var isRecording = false;
var performanceJSON = { "avatarClips" : [] }; var performanceJSON = { "avatarClips" : [] };
var responsesExpected = 0; var responsesExpected = 0;
var readyToPrintInfo = false;
var performanceFileURL = null;
var waitingForPerformanceFile = true; var waitingForPerformanceFile = true;
var totalWaitingTime = 0; var totalWaitingTime = 0;
var extension = "txt"; var extension = "txt";
@ -71,9 +74,9 @@ function mousePressEvent(event) {
print("I'm the master. I want to start recording"); print("I'm the master. I want to start recording");
Messages.sendMessage(MASTER_TO_CLIENTS_CHANNEL, START_MESSAGE); Messages.sendMessage(MASTER_TO_CLIENTS_CHANNEL, START_MESSAGE);
isRecording = true; isRecording = true;
waitingForPerformanceFile = true;
} else { } else {
print("I want to stop recording"); print("I want to stop recording");
waitingForPerformanceFile = true;
Script.update.connect(update); Script.update.connect(update);
Messages.sendMessage(MASTER_TO_CLIENTS_CHANNEL, STOP_MESSAGE); Messages.sendMessage(MASTER_TO_CLIENTS_CHANNEL, STOP_MESSAGE);
isRecording = false; isRecording = false;
@ -108,29 +111,38 @@ function update(deltaTime) {
} }
//clean things after upload performance file to asset //clean things after upload performance file to asset
waitingForPerformanceFile = false; waitingForPerformanceFile = false;
responsesExpected = 0;
totalWaitingTime = 0; totalWaitingTime = 0;
Script.update.disconnect(update); Script.update.disconnect(update);
}
} else if (readyToPrintInfo == true){
Window.prompt("Performance file and clips: ", getUtilityString());
responsesExpected = 0;
performanceJSON = { "avatarClips" : [] }; 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){ function uploadFinished(url){
//need to print somehow the url here this way the master can copy the 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("some info:");
print("downloaded performance file from asset and examinating its content..."); performanceFileURL = url;
var avatarClips = obj.avatarClips; print("PERFORMANCE FILE URL: " + performanceFileURL);
print("number of clips obtained:" + responsesExpected);
var avatarClips = performanceJSON.avatarClips;
avatarClips.forEach(function(param) { avatarClips.forEach(function(param) {
print("clip url obtained: " + param); print("clip url obtained: " + param);
}); });
readyToPrintInfo = true;
Script.update.connect(update);
} }
function cleanup() { function cleanup() {