mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
not load the last recording
This commit is contained in:
parent
b4934275e1
commit
1f854784e1
3 changed files with 36 additions and 73 deletions
|
@ -1,3 +1,4 @@
|
|||
var PARAMS_SCRIPT_URL = Script.resolvePath('recordingEntityScript.js');
|
||||
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
||||
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(6, Quat.getFront(rotation)));
|
||||
|
@ -17,5 +18,6 @@ var recordAreaEntity = Entities.addEntity({
|
|||
blue: 255
|
||||
},
|
||||
visible: true,
|
||||
script: "https://hifi-public.s3.amazonaws.com/sam/record/recordingEntityScript.js",
|
||||
script: PARAMS_SCRIPT_URL,
|
||||
ignoreForCollision: true,
|
||||
});
|
|
@ -12,31 +12,25 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
||||
(function () {
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/utils.js");
|
||||
|
||||
var insideRecorderArea = false;
|
||||
var enteredInTime = false;
|
||||
var isAvatarRecording = false;
|
||||
var _this;
|
||||
var isAvatarRecording = false;
|
||||
var channel = "groupRecordingChannel";
|
||||
var startMessage = "RECONDING STARTED";
|
||||
var stopMessage = "RECONDING ENDED";
|
||||
|
||||
function recordingEntity() {
|
||||
_this = this;
|
||||
return;
|
||||
}
|
||||
|
||||
function update() {
|
||||
var isRecordingStarted = getEntityCustomData("recordingKey", _this.entityID, { isRecordingStarted: false }).isRecordingStarted;
|
||||
if (isRecordingStarted && !isAvatarRecording) {
|
||||
function receivingMessage(channel, message, senderID) {
|
||||
print("message received on channel:" + channel + ", message:" + message + ", senderID:" + senderID);
|
||||
if(message === startMessage) {
|
||||
_this.startRecording();
|
||||
} else if ((!isRecordingStarted && isAvatarRecording) || (isAvatarRecording && !insideRecorderArea)) {
|
||||
} else if(message === stopMessage) {
|
||||
_this.stopRecording();
|
||||
} else if (!isRecordingStarted && insideRecorderArea && !enteredInTime) {
|
||||
//if an avatar enters the zone while a recording is started he will be able to participate to the next group recording
|
||||
enteredInTime = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,37 +39,29 @@
|
|||
preload: function (entityID) {
|
||||
print("RECORDING ENTITY PRELOAD");
|
||||
this.entityID = entityID;
|
||||
|
||||
|
||||
var entityProperties = Entities.getEntityProperties(_this.entityID);
|
||||
if (!entityProperties.ignoreForCollisions) {
|
||||
Entities.editEntity(_this.entityID, { ignoreForCollisions: true });
|
||||
}
|
||||
|
||||
//print(JSON.stringify(entityProperties));
|
||||
var recordingKey = getEntityCustomData("recordingKey", _this.entityID, undefined);
|
||||
if (recordingKey === undefined) {
|
||||
setEntityCustomData("recordingKey", _this.entityID, { isRecordingStarted: false });
|
||||
}
|
||||
|
||||
Script.update.connect(update);
|
||||
Messages.messageReceived.connect(receivingMessage);
|
||||
},
|
||||
|
||||
enterEntity: function (entityID) {
|
||||
print("entering in the recording area");
|
||||
insideRecorderArea = true;
|
||||
var isRecordingStarted = getEntityCustomData("recordingKey", _this.entityID, { isRecordingStarted: false }).isRecordingStarted;
|
||||
if (!isRecordingStarted) {
|
||||
//i'm in the recording area in time (before the event starts)
|
||||
enteredInTime = true;
|
||||
}
|
||||
Messages.subscribe(channel);
|
||||
|
||||
},
|
||||
|
||||
leaveEntity: function (entityID) {
|
||||
print("leaving the recording area");
|
||||
insideRecorderArea = false;
|
||||
enteredInTime = false;
|
||||
_this.stopRecording();
|
||||
Messages.unsubscribe(channel);
|
||||
},
|
||||
|
||||
startRecording: function (entityID) {
|
||||
if (enteredInTime && !isAvatarRecording) {
|
||||
if (!isAvatarRecording) {
|
||||
print("RECORDING STARTED");
|
||||
Recording.startRecording();
|
||||
isAvatarRecording = true;
|
||||
|
@ -86,7 +72,6 @@
|
|||
if (isAvatarRecording) {
|
||||
print("RECORDING ENDED");
|
||||
Recording.stopRecording();
|
||||
Recording.loadLastRecording();
|
||||
isAvatarRecording = false;
|
||||
recordingFile = Window.save("Save recording to file", "./groupRecording", "Recordings (*.hfr)");
|
||||
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
||||
|
@ -94,13 +79,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
unload: function (entityID) {
|
||||
print("RECORDING ENTITY UNLOAD");
|
||||
Script.update.disconnect(update);
|
||||
_this.stopRecording();
|
||||
Messages.unsubscribe(channel);
|
||||
Messages.messageReceived.disconnect(receivingMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new recordingEntity();
|
||||
});
|
|
@ -5,18 +5,15 @@
|
|||
// Created by Alessandro Signa on 11/12/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Run this script to find the recorder (created by crateRecorder.js) and drive the start/end of the recording for anyone who is inside the box
|
||||
// Run this script to spawn a box (recorder) and drive the start/end of the recording for anyone who is inside the box
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/toolBars.js");
|
||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/utils.js");
|
||||
|
||||
|
||||
|
||||
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
||||
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(rotation)));
|
||||
|
@ -28,27 +25,9 @@ var COLOR_TOOL_BAR = { red: 0, green: 0, blue: 0 };
|
|||
|
||||
var toolBar = null;
|
||||
var recordIcon;
|
||||
|
||||
var isRecordingEntityFound = false;
|
||||
|
||||
var isRecording = false;
|
||||
|
||||
var recordAreaEntity = null;
|
||||
findRecorder();
|
||||
|
||||
function findRecorder() {
|
||||
foundEntities = Entities.findEntities(MyAvatar.position, 50);
|
||||
for (var i = 0; i < foundEntities.length; i++) {
|
||||
var name = Entities.getEntityProperties(foundEntities[i], "name").name;
|
||||
if (name === "recorderEntity") {
|
||||
recordAreaEntity = foundEntities[i];
|
||||
isRecordingEntityFound = true;
|
||||
print("Found recorder Entity!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var channel = "groupRecordingChannel";
|
||||
Messages.subscribe(channel);
|
||||
setupToolBar();
|
||||
|
||||
function setupToolBar() {
|
||||
|
@ -58,9 +37,7 @@ function setupToolBar() {
|
|||
}
|
||||
Tool.IMAGE_HEIGHT /= 2;
|
||||
Tool.IMAGE_WIDTH /= 2;
|
||||
|
||||
toolBar = new ToolBar(0, 100, ToolBar.HORIZONTAL); //put the button in the up-left corner
|
||||
|
||||
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
||||
|
||||
recordIcon = toolBar.addTool({
|
||||
|
@ -70,7 +47,7 @@ function setupToolBar() {
|
|||
width: Tool.IMAGE_WIDTH,
|
||||
height: Tool.IMAGE_HEIGHT,
|
||||
alpha: Recording.isPlaying() ? ALPHA_OFF : ALPHA_ON,
|
||||
visible: isRecordingEntityFound,
|
||||
visible: true,
|
||||
}, true, isRecording);
|
||||
}
|
||||
|
||||
|
@ -79,24 +56,22 @@ function mousePressEvent(event) {
|
|||
if (recordIcon === toolBar.clicked(clickedOverlay, false)) {
|
||||
if (!isRecording) {
|
||||
print("I'm the master. I want to start recording");
|
||||
var message = "RECONDING STARTED";
|
||||
Messages.sendMessage(channel, message);
|
||||
isRecording = true;
|
||||
setEntityCustomData("recordingKey", recordAreaEntity, {isRecordingStarted: true});
|
||||
|
||||
} else {
|
||||
print("I want to stop recording");
|
||||
var message = "RECONDING ENDED";
|
||||
Messages.sendMessage(channel, message);
|
||||
isRecording = false;
|
||||
setEntityCustomData("recordingKey", recordAreaEntity, {isRecordingStarted: false});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function cleanup() {
|
||||
toolBar.cleanup();
|
||||
Messages.unsubscribe(channel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
|
|
Loading…
Reference in a new issue