mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:06:41 +02:00
modify scripts to use new recording API
This commit is contained in:
parent
c7a28a527a
commit
1b24538756
7 changed files with 80 additions and 59 deletions
|
@ -138,7 +138,13 @@ Agent.isAvatar = true;
|
||||||
Agent.isListeningToAudioStream = true;
|
Agent.isListeningToAudioStream = true;
|
||||||
Avatar.skeletonModelURL = AVATAR_URL; // FIXME - currently setting an avatar while playing a recording doesn't work it will be ignored
|
Avatar.skeletonModelURL = AVATAR_URL; // FIXME - currently setting an avatar while playing a recording doesn't work it will be ignored
|
||||||
|
|
||||||
Recording.loadRecording(RECORDING_URL);
|
Recording.loadRecording(RECORDING_URL, function(success) {
|
||||||
|
if (success) {
|
||||||
|
Script.update.connect(update);
|
||||||
|
} else {
|
||||||
|
print("Failed to load recording from " + RECORDING_URL);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
count = 300; // This is necessary to wait for the audio mixer to connect
|
count = 300; // This is necessary to wait for the audio mixer to connect
|
||||||
function update(event) {
|
function update(event) {
|
||||||
|
@ -174,10 +180,8 @@ function update(event) {
|
||||||
+" FT: " + Avatar.getDataRate("faceTrackerOutbound").toFixed(2) + "\n"
|
+" FT: " + Avatar.getDataRate("faceTrackerOutbound").toFixed(2) + "\n"
|
||||||
+" JD: " + Avatar.getDataRate("jointDataOutbound").toFixed(2));
|
+" JD: " + Avatar.getDataRate("jointDataOutbound").toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Recording.isPlaying()) {
|
if (!Recording.isPlaying()) {
|
||||||
Script.update.disconnect(update);
|
Script.update.disconnect(update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(update);
|
|
||||||
|
|
|
@ -20,7 +20,11 @@ Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
||||||
Avatar.scale = 1.0;
|
Avatar.scale = 1.0;
|
||||||
Agent.isAvatar = true;
|
Agent.isAvatar = true;
|
||||||
|
|
||||||
Recording.loadRecording(recordingFile);
|
Recording.loadRecording(recordingFile, function(success) {
|
||||||
|
if (success) {
|
||||||
|
Script.update.connect(update);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
count = 300; // This is necessary to wait for the audio mixer to connect
|
count = 300; // This is necessary to wait for the audio mixer to connect
|
||||||
function update(event) {
|
function update(event) {
|
||||||
|
@ -39,10 +43,8 @@ function update(event) {
|
||||||
Vec3.print("Playing from ", Avatar.position);
|
Vec3.print("Playing from ", Avatar.position);
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Recording.isPlaying()) {
|
if (!Recording.isPlaying()) {
|
||||||
Script.update.disconnect(update);
|
Script.update.disconnect(update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(update);
|
|
||||||
|
|
|
@ -42,10 +42,13 @@ var playRecording = function() {
|
||||||
Recording.setPlayerLoop(false);
|
Recording.setPlayerLoop(false);
|
||||||
Recording.setPlayerTime(STARTING_TIME);
|
Recording.setPlayerTime(STARTING_TIME);
|
||||||
Recording.setPlayerAudioOffset(AUDIO_OFFSET);
|
Recording.setPlayerAudioOffset(AUDIO_OFFSET);
|
||||||
Recording.loadRecording(CLIP_URL);
|
Recording.loadRecording(CLIP_URL, function(success) {
|
||||||
Recording.startPlaying();
|
if (success) {
|
||||||
isPlaying = true;
|
Recording.startPlaying();
|
||||||
isPlayable = false; // Set this true again after the cooldown period
|
isPlaying = true;
|
||||||
|
isPlayable = false; // Set this true again after the cooldown period
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Script.update.connect(function(deltaTime) {
|
Script.update.connect(function(deltaTime) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
var origin = {x: 512, y: 512, z: 512};
|
var origin = {x: 512, y: 512, z: 512};
|
||||||
var millisecondsToWaitBeforeStarting = 2 * 1000; // To give the various servers a chance to start.
|
var millisecondsToWaitBeforeStarting = 2 * 1000; // To give the various servers a chance to start.
|
||||||
var millisecondsToWaitBeforeEnding = 30 * 1000;
|
var millisecondsToWaitBeforeEnding = 30 * 1000;
|
||||||
|
|
||||||
Avatar.skeletonModelURL = "https://hifi-public.s3.amazonaws.com/marketplace/contents/dd03b8e3-52fb-4ab3-9ac9-3b17e00cd85d/98baa90b3b66803c5d7bd4537fca6993.fst"; //lovejoy
|
Avatar.skeletonModelURL = "https://hifi-public.s3.amazonaws.com/marketplace/contents/dd03b8e3-52fb-4ab3-9ac9-3b17e00cd85d/98baa90b3b66803c5d7bd4537fca6993.fst"; //lovejoy
|
||||||
Avatar.displayName = "AC Avatar";
|
Avatar.displayName = "AC Avatar";
|
||||||
|
@ -10,9 +10,11 @@ Agent.isAvatar = true;
|
||||||
|
|
||||||
Script.setTimeout(function () {
|
Script.setTimeout(function () {
|
||||||
Avatar.position = origin;
|
Avatar.position = origin;
|
||||||
Recording.loadRecording("d:/hifi.rec");
|
Recording.loadRecording("d:/hifi.rec", function(success){
|
||||||
Recording.setPlayerLoop(true);
|
Recording.setPlayerLoop(true);
|
||||||
Recording.startPlaying();
|
Recording.startPlaying();
|
||||||
|
});
|
||||||
|
|
||||||
}, millisecondsToWaitBeforeStarting);
|
}, millisecondsToWaitBeforeStarting);
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,4 +23,4 @@ Script.setTimeout(function () {
|
||||||
Agent.isAvatar = false;
|
Agent.isAvatar = false;
|
||||||
Recording.stopPlaying();
|
Recording.stopPlaying();
|
||||||
Script.stop();
|
Script.stop();
|
||||||
}, millisecondsToWaitBeforeEnding);
|
}, millisecondsToWaitBeforeEnding);
|
||||||
|
|
|
@ -26,7 +26,7 @@ var PLAY = "Play";
|
||||||
function getAction(channel, message, senderID) {
|
function getAction(channel, message, senderID) {
|
||||||
if(subscribed) {
|
if(subscribed) {
|
||||||
print("I'm the agent and I received this: " + message);
|
print("I'm the agent and I received this: " + message);
|
||||||
|
|
||||||
switch(message) {
|
switch(message) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
print("Play");
|
print("Play");
|
||||||
|
@ -35,7 +35,7 @@ function getAction(channel, message, senderID) {
|
||||||
Recording.startPlaying();
|
Recording.startPlaying();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
print("Unknown action: " + action);
|
print("Unknown action: " + action);
|
||||||
break;
|
break;
|
||||||
|
@ -49,16 +49,19 @@ function update(deltaTime) {
|
||||||
totalTime += deltaTime;
|
totalTime += deltaTime;
|
||||||
|
|
||||||
if (totalTime > WAIT_FOR_AUDIO_MIXER) {
|
if (totalTime > WAIT_FOR_AUDIO_MIXER) {
|
||||||
if (!subscribed) {
|
if (!subscribed) {
|
||||||
Messages.subscribe(PLAYBACK_CHANNEL);
|
Messages.subscribe(PLAYBACK_CHANNEL);
|
||||||
subscribed = true;
|
subscribed = true;
|
||||||
Recording.loadRecording(clip_url);
|
Recording.loadRecording(clip_url, function(success) {
|
||||||
Recording.setPlayFromCurrentLocation(playFromCurrentLocation);
|
if (success) {
|
||||||
Recording.setPlayerUseDisplayName(useDisplayName);
|
Recording.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||||
Recording.setPlayerUseAttachments(useAttachments);
|
Recording.setPlayerUseDisplayName(useDisplayName);
|
||||||
Recording.setPlayerUseHeadModel(false);
|
Recording.setPlayerUseAttachments(useAttachments);
|
||||||
Recording.setPlayerUseSkeletonModel(useAvatarModel);
|
Recording.setPlayerUseHeadModel(false);
|
||||||
Agent.isAvatar = true;
|
Recording.setPlayerUseSkeletonModel(useAvatarModel);
|
||||||
|
Agent.isAvatar = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,4 +73,4 @@ Messages.messageReceived.connect(function (channel, message, senderID) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
|
|
||||||
var command = null;
|
var command = null;
|
||||||
var clip_url = null;
|
var clip_url = null;
|
||||||
|
|
||||||
var REVIEW_CHANNEL = "reviewChannel";
|
var REVIEW_CHANNEL = "reviewChannel";
|
||||||
var playFromCurrentLocation = true;
|
var playFromCurrentLocation = true;
|
||||||
|
@ -28,16 +28,16 @@ var HIDE = "Hide";
|
||||||
function getAction(channel, message, senderID) {
|
function getAction(channel, message, senderID) {
|
||||||
if(subscribed) {
|
if(subscribed) {
|
||||||
print("I'm the agent and I received this: " + message);
|
print("I'm the agent and I received this: " + message);
|
||||||
|
|
||||||
if (Recording.isPlaying()) {
|
if (Recording.isPlaying()) {
|
||||||
Recording.stopPlaying();
|
Recording.stopPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
m = JSON.parse(message);
|
m = JSON.parse(message);
|
||||||
|
|
||||||
command = m.command;
|
command = m.command;
|
||||||
clip_url = m.clip_url;
|
clip_url = m.clip_url;
|
||||||
|
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
print("Play");
|
print("Play");
|
||||||
|
@ -46,21 +46,25 @@ function getAction(channel, message, senderID) {
|
||||||
Recording.startPlaying();
|
Recording.startPlaying();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW:
|
case SHOW:
|
||||||
print("Show");
|
print("Show");
|
||||||
Recording.loadRecording(clip_url);
|
Recording.loadRecording(clip_url, function(success){
|
||||||
Agent.isAvatar = true;
|
if (success) {
|
||||||
Recording.setPlayerTime(0.0);
|
Agent.isAvatar = true;
|
||||||
Recording.startPlaying();
|
Recording.setPlayerTime(0.0);
|
||||||
Recording.stopPlaying();
|
Recording.startPlaying();
|
||||||
|
Recording.stopPlaying();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HIDE:
|
case HIDE:
|
||||||
print("Hide");
|
print("Hide");
|
||||||
Agent.isAvatar = false;
|
Agent.isAvatar = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
print("Unknown action: " + action);
|
print("Unknown action: " + action);
|
||||||
break;
|
break;
|
||||||
|
@ -74,7 +78,7 @@ function update(deltaTime) {
|
||||||
totalTime += deltaTime;
|
totalTime += deltaTime;
|
||||||
|
|
||||||
if (totalTime > WAIT_FOR_AUDIO_MIXER) {
|
if (totalTime > WAIT_FOR_AUDIO_MIXER) {
|
||||||
if (!subscribed) {
|
if (!subscribed) {
|
||||||
Messages.subscribe(REVIEW_CHANNEL);
|
Messages.subscribe(REVIEW_CHANNEL);
|
||||||
subscribed = true;
|
subscribed = true;
|
||||||
Recording.setPlayFromCurrentLocation(playFromCurrentLocation);
|
Recording.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||||
|
@ -93,4 +97,4 @@ Messages.messageReceived.connect(function (channel, message, senderID) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
|
|
|
@ -55,13 +55,13 @@ function setupToolBar() {
|
||||||
}
|
}
|
||||||
Tool.IMAGE_HEIGHT /= 2;
|
Tool.IMAGE_HEIGHT /= 2;
|
||||||
Tool.IMAGE_WIDTH /= 2;
|
Tool.IMAGE_WIDTH /= 2;
|
||||||
|
|
||||||
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL);
|
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL);
|
||||||
|
|
||||||
toolBar.onMove = onToolbarMove;
|
toolBar.onMove = onToolbarMove;
|
||||||
|
|
||||||
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
||||||
|
|
||||||
recordIcon = toolBar.addTool({
|
recordIcon = toolBar.addTool({
|
||||||
imageURL: TOOL_ICON_URL + "recording-record.svg",
|
imageURL: TOOL_ICON_URL + "recording-record.svg",
|
||||||
subImage: { x: 0, y: 0, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
subImage: { x: 0, y: 0, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||||
|
@ -71,7 +71,7 @@ function setupToolBar() {
|
||||||
alpha: Recording.isPlaying() ? ALPHA_OFF : ALPHA_ON,
|
alpha: Recording.isPlaying() ? ALPHA_OFF : ALPHA_ON,
|
||||||
visible: true
|
visible: true
|
||||||
}, true, !Recording.isRecording());
|
}, true, !Recording.isRecording());
|
||||||
|
|
||||||
var playLoopWidthFactor = 1.65;
|
var playLoopWidthFactor = 1.65;
|
||||||
playIcon = toolBar.addTool({
|
playIcon = toolBar.addTool({
|
||||||
imageURL: TOOL_ICON_URL + "play-pause.svg",
|
imageURL: TOOL_ICON_URL + "play-pause.svg",
|
||||||
|
@ -80,7 +80,7 @@ function setupToolBar() {
|
||||||
alpha: (Recording.isRecording() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
alpha: (Recording.isRecording() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
||||||
visible: true
|
visible: true
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
playLoopIcon = toolBar.addTool({
|
playLoopIcon = toolBar.addTool({
|
||||||
imageURL: TOOL_ICON_URL + "play-and-loop.svg",
|
imageURL: TOOL_ICON_URL + "play-and-loop.svg",
|
||||||
subImage: { x: 0, y: 0, width: playLoopWidthFactor * Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
subImage: { x: 0, y: 0, width: playLoopWidthFactor * Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
|
||||||
|
@ -89,10 +89,10 @@ function setupToolBar() {
|
||||||
alpha: (Recording.isRecording() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
alpha: (Recording.isRecording() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
||||||
visible: true
|
visible: true
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
timerOffset = toolBar.width + ToolBar.SPACING;
|
timerOffset = toolBar.width + ToolBar.SPACING;
|
||||||
spacing = toolBar.addSpacing(0);
|
spacing = toolBar.addSpacing(0);
|
||||||
|
|
||||||
saveIcon = toolBar.addTool({
|
saveIcon = toolBar.addTool({
|
||||||
imageURL: TOOL_ICON_URL + "recording-save.svg",
|
imageURL: TOOL_ICON_URL + "recording-save.svg",
|
||||||
width: Tool.IMAGE_WIDTH,
|
width: Tool.IMAGE_WIDTH,
|
||||||
|
@ -100,7 +100,7 @@ function setupToolBar() {
|
||||||
alpha: (Recording.isRecording() || Recording.isPlaying() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
alpha: (Recording.isRecording() || Recording.isPlaying() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
||||||
visible: true
|
visible: true
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
loadIcon = toolBar.addTool({
|
loadIcon = toolBar.addTool({
|
||||||
imageURL: TOOL_ICON_URL + "recording-upload.svg",
|
imageURL: TOOL_ICON_URL + "recording-upload.svg",
|
||||||
width: Tool.IMAGE_WIDTH,
|
width: Tool.IMAGE_WIDTH,
|
||||||
|
@ -153,10 +153,10 @@ function onToolbarMove(newX, newY, deltaX, deltaY) {
|
||||||
x: newX + timerOffset - ToolBar.SPACING,
|
x: newX + timerOffset - ToolBar.SPACING,
|
||||||
y: newY
|
y: newY
|
||||||
});
|
});
|
||||||
|
|
||||||
slider.x = newX - ToolBar.SPACING;
|
slider.x = newX - ToolBar.SPACING;
|
||||||
slider.y = newY - slider.h - ToolBar.SPACING;
|
slider.y = newY - slider.h - ToolBar.SPACING;
|
||||||
|
|
||||||
Overlays.editOverlay(slider.background, {
|
Overlays.editOverlay(slider.background, {
|
||||||
x: slider.x,
|
x: slider.x,
|
||||||
y: slider.y
|
y: slider.y
|
||||||
|
@ -182,13 +182,13 @@ function updateTimer() {
|
||||||
width: timerWidth
|
width: timerWidth
|
||||||
});
|
});
|
||||||
toolBar.changeSpacing(timerWidth + ToolBar.SPACING, spacing);
|
toolBar.changeSpacing(timerWidth + ToolBar.SPACING, spacing);
|
||||||
|
|
||||||
if (Recording.isRecording()) {
|
if (Recording.isRecording()) {
|
||||||
slider.pos = 1.0;
|
slider.pos = 1.0;
|
||||||
} else if (Recording.playerLength() > 0) {
|
} else if (Recording.playerLength() > 0) {
|
||||||
slider.pos = Recording.playerElapsed() / Recording.playerLength();
|
slider.pos = Recording.playerElapsed() / Recording.playerLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlays.editOverlay(slider.foreground, {
|
Overlays.editOverlay(slider.foreground, {
|
||||||
width: slider.pos * slider.w
|
width: slider.pos * slider.w
|
||||||
});
|
});
|
||||||
|
@ -221,7 +221,7 @@ function moveUI() {
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||||
|
|
||||||
if (recordIcon === toolBar.clicked(clickedOverlay, false) && !Recording.isPlaying()) {
|
if (recordIcon === toolBar.clicked(clickedOverlay, false) && !Recording.isPlaying()) {
|
||||||
if (!Recording.isRecording()) {
|
if (!Recording.isRecording()) {
|
||||||
Recording.startRecording();
|
Recording.startRecording();
|
||||||
|
@ -281,8 +281,11 @@ function mousePressEvent(event) {
|
||||||
if (!Recording.isRecording() && !Recording.isPlaying()) {
|
if (!Recording.isRecording() && !Recording.isPlaying()) {
|
||||||
recordingFile = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
|
recordingFile = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
|
||||||
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
||||||
Recording.loadRecording(recordingFile);
|
Recording.loadRecording(recordingFile, function(success) {
|
||||||
setDefaultPlayerOptions();
|
if (success) {
|
||||||
|
setDefaultPlayerOptions();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (Recording.playerLength() > 0) {
|
if (Recording.playerLength() > 0) {
|
||||||
toolBar.setAlpha(ALPHA_ON, playIcon);
|
toolBar.setAlpha(ALPHA_ON, playIcon);
|
||||||
|
@ -323,7 +326,7 @@ function update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimer();
|
updateTimer();
|
||||||
|
|
||||||
if (watchStop && !Recording.isPlaying()) {
|
if (watchStop && !Recording.isPlaying()) {
|
||||||
watchStop = false;
|
watchStop = false;
|
||||||
toolBar.setAlpha(ALPHA_ON, recordIcon);
|
toolBar.setAlpha(ALPHA_ON, recordIcon);
|
||||||
|
|
Loading…
Reference in a new issue