mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 10:02:24 +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;
|
||||
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
|
||||
function update(event) {
|
||||
|
@ -174,10 +180,8 @@ function update(event) {
|
|||
+" FT: " + Avatar.getDataRate("faceTrackerOutbound").toFixed(2) + "\n"
|
||||
+" JD: " + Avatar.getDataRate("jointDataOutbound").toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
if (!Recording.isPlaying()) {
|
||||
Script.update.disconnect(update);
|
||||
}
|
||||
}
|
||||
|
||||
Script.update.connect(update);
|
||||
|
|
|
@ -20,7 +20,11 @@ Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
|||
Avatar.scale = 1.0;
|
||||
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
|
||||
function update(event) {
|
||||
|
@ -39,10 +43,8 @@ function update(event) {
|
|||
Vec3.print("Playing from ", Avatar.position);
|
||||
count--;
|
||||
}
|
||||
|
||||
|
||||
if (!Recording.isPlaying()) {
|
||||
Script.update.disconnect(update);
|
||||
}
|
||||
}
|
||||
|
||||
Script.update.connect(update);
|
||||
|
|
|
@ -42,10 +42,13 @@ var playRecording = function() {
|
|||
Recording.setPlayerLoop(false);
|
||||
Recording.setPlayerTime(STARTING_TIME);
|
||||
Recording.setPlayerAudioOffset(AUDIO_OFFSET);
|
||||
Recording.loadRecording(CLIP_URL);
|
||||
Recording.startPlaying();
|
||||
isPlaying = true;
|
||||
isPlayable = false; // Set this true again after the cooldown period
|
||||
Recording.loadRecording(CLIP_URL, function(success) {
|
||||
if (success) {
|
||||
Recording.startPlaying();
|
||||
isPlaying = true;
|
||||
isPlayable = false; // Set this true again after the cooldown period
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Script.update.connect(function(deltaTime) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var origin = {x: 512, y: 512, z: 512};
|
||||
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.displayName = "AC Avatar";
|
||||
|
@ -10,9 +10,11 @@ Agent.isAvatar = true;
|
|||
|
||||
Script.setTimeout(function () {
|
||||
Avatar.position = origin;
|
||||
Recording.loadRecording("d:/hifi.rec");
|
||||
Recording.setPlayerLoop(true);
|
||||
Recording.startPlaying();
|
||||
Recording.loadRecording("d:/hifi.rec", function(success){
|
||||
Recording.setPlayerLoop(true);
|
||||
Recording.startPlaying();
|
||||
});
|
||||
|
||||
}, millisecondsToWaitBeforeStarting);
|
||||
|
||||
|
||||
|
@ -21,4 +23,4 @@ Script.setTimeout(function () {
|
|||
Agent.isAvatar = false;
|
||||
Recording.stopPlaying();
|
||||
Script.stop();
|
||||
}, millisecondsToWaitBeforeEnding);
|
||||
}, millisecondsToWaitBeforeEnding);
|
||||
|
|
|
@ -26,7 +26,7 @@ var PLAY = "Play";
|
|||
function getAction(channel, message, senderID) {
|
||||
if(subscribed) {
|
||||
print("I'm the agent and I received this: " + message);
|
||||
|
||||
|
||||
switch(message) {
|
||||
case PLAY:
|
||||
print("Play");
|
||||
|
@ -35,7 +35,7 @@ function getAction(channel, message, senderID) {
|
|||
Recording.startPlaying();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
print("Unknown action: " + action);
|
||||
break;
|
||||
|
@ -49,16 +49,19 @@ function update(deltaTime) {
|
|||
totalTime += deltaTime;
|
||||
|
||||
if (totalTime > WAIT_FOR_AUDIO_MIXER) {
|
||||
if (!subscribed) {
|
||||
if (!subscribed) {
|
||||
Messages.subscribe(PLAYBACK_CHANNEL);
|
||||
subscribed = true;
|
||||
Recording.loadRecording(clip_url);
|
||||
Recording.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||
Recording.setPlayerUseDisplayName(useDisplayName);
|
||||
Recording.setPlayerUseAttachments(useAttachments);
|
||||
Recording.setPlayerUseHeadModel(false);
|
||||
Recording.setPlayerUseSkeletonModel(useAvatarModel);
|
||||
Agent.isAvatar = true;
|
||||
Recording.loadRecording(clip_url, function(success) {
|
||||
if (success) {
|
||||
Recording.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||
Recording.setPlayerUseDisplayName(useDisplayName);
|
||||
Recording.setPlayerUseAttachments(useAttachments);
|
||||
Recording.setPlayerUseHeadModel(false);
|
||||
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 clip_url = null;
|
||||
var clip_url = null;
|
||||
|
||||
var REVIEW_CHANNEL = "reviewChannel";
|
||||
var playFromCurrentLocation = true;
|
||||
|
@ -28,16 +28,16 @@ var HIDE = "Hide";
|
|||
function getAction(channel, message, senderID) {
|
||||
if(subscribed) {
|
||||
print("I'm the agent and I received this: " + message);
|
||||
|
||||
|
||||
if (Recording.isPlaying()) {
|
||||
Recording.stopPlaying();
|
||||
}
|
||||
|
||||
|
||||
m = JSON.parse(message);
|
||||
|
||||
|
||||
command = m.command;
|
||||
clip_url = m.clip_url;
|
||||
|
||||
|
||||
switch(command) {
|
||||
case PLAY:
|
||||
print("Play");
|
||||
|
@ -46,21 +46,25 @@ function getAction(channel, message, senderID) {
|
|||
Recording.startPlaying();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case SHOW:
|
||||
print("Show");
|
||||
Recording.loadRecording(clip_url);
|
||||
Agent.isAvatar = true;
|
||||
Recording.setPlayerTime(0.0);
|
||||
Recording.startPlaying();
|
||||
Recording.stopPlaying();
|
||||
Recording.loadRecording(clip_url, function(success){
|
||||
if (success) {
|
||||
Agent.isAvatar = true;
|
||||
Recording.setPlayerTime(0.0);
|
||||
Recording.startPlaying();
|
||||
Recording.stopPlaying();
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case HIDE:
|
||||
print("Hide");
|
||||
Agent.isAvatar = false;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
print("Unknown action: " + action);
|
||||
break;
|
||||
|
@ -74,7 +78,7 @@ function update(deltaTime) {
|
|||
totalTime += deltaTime;
|
||||
|
||||
if (totalTime > WAIT_FOR_AUDIO_MIXER) {
|
||||
if (!subscribed) {
|
||||
if (!subscribed) {
|
||||
Messages.subscribe(REVIEW_CHANNEL);
|
||||
subscribed = true;
|
||||
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_WIDTH /= 2;
|
||||
|
||||
|
||||
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL);
|
||||
|
||||
|
||||
toolBar.onMove = onToolbarMove;
|
||||
|
||||
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
||||
|
||||
|
||||
recordIcon = toolBar.addTool({
|
||||
imageURL: TOOL_ICON_URL + "recording-record.svg",
|
||||
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,
|
||||
visible: true
|
||||
}, true, !Recording.isRecording());
|
||||
|
||||
|
||||
var playLoopWidthFactor = 1.65;
|
||||
playIcon = toolBar.addTool({
|
||||
imageURL: TOOL_ICON_URL + "play-pause.svg",
|
||||
|
@ -80,7 +80,7 @@ function setupToolBar() {
|
|||
alpha: (Recording.isRecording() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
||||
visible: true
|
||||
}, false);
|
||||
|
||||
|
||||
playLoopIcon = toolBar.addTool({
|
||||
imageURL: TOOL_ICON_URL + "play-and-loop.svg",
|
||||
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,
|
||||
visible: true
|
||||
}, false);
|
||||
|
||||
|
||||
timerOffset = toolBar.width + ToolBar.SPACING;
|
||||
spacing = toolBar.addSpacing(0);
|
||||
|
||||
|
||||
saveIcon = toolBar.addTool({
|
||||
imageURL: TOOL_ICON_URL + "recording-save.svg",
|
||||
width: Tool.IMAGE_WIDTH,
|
||||
|
@ -100,7 +100,7 @@ function setupToolBar() {
|
|||
alpha: (Recording.isRecording() || Recording.isPlaying() || Recording.playerLength() === 0) ? ALPHA_OFF : ALPHA_ON,
|
||||
visible: true
|
||||
}, false);
|
||||
|
||||
|
||||
loadIcon = toolBar.addTool({
|
||||
imageURL: TOOL_ICON_URL + "recording-upload.svg",
|
||||
width: Tool.IMAGE_WIDTH,
|
||||
|
@ -153,10 +153,10 @@ function onToolbarMove(newX, newY, deltaX, deltaY) {
|
|||
x: newX + timerOffset - ToolBar.SPACING,
|
||||
y: newY
|
||||
});
|
||||
|
||||
|
||||
slider.x = newX - ToolBar.SPACING;
|
||||
slider.y = newY - slider.h - ToolBar.SPACING;
|
||||
|
||||
|
||||
Overlays.editOverlay(slider.background, {
|
||||
x: slider.x,
|
||||
y: slider.y
|
||||
|
@ -182,13 +182,13 @@ function updateTimer() {
|
|||
width: timerWidth
|
||||
});
|
||||
toolBar.changeSpacing(timerWidth + ToolBar.SPACING, spacing);
|
||||
|
||||
|
||||
if (Recording.isRecording()) {
|
||||
slider.pos = 1.0;
|
||||
} else if (Recording.playerLength() > 0) {
|
||||
slider.pos = Recording.playerElapsed() / Recording.playerLength();
|
||||
}
|
||||
|
||||
|
||||
Overlays.editOverlay(slider.foreground, {
|
||||
width: slider.pos * slider.w
|
||||
});
|
||||
|
@ -221,7 +221,7 @@ function moveUI() {
|
|||
|
||||
function mousePressEvent(event) {
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
|
||||
|
||||
if (recordIcon === toolBar.clicked(clickedOverlay, false) && !Recording.isPlaying()) {
|
||||
if (!Recording.isRecording()) {
|
||||
Recording.startRecording();
|
||||
|
@ -281,8 +281,11 @@ function mousePressEvent(event) {
|
|||
if (!Recording.isRecording() && !Recording.isPlaying()) {
|
||||
recordingFile = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
|
||||
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
||||
Recording.loadRecording(recordingFile);
|
||||
setDefaultPlayerOptions();
|
||||
Recording.loadRecording(recordingFile, function(success) {
|
||||
if (success) {
|
||||
setDefaultPlayerOptions();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Recording.playerLength() > 0) {
|
||||
toolBar.setAlpha(ALPHA_ON, playIcon);
|
||||
|
@ -323,7 +326,7 @@ function update() {
|
|||
}
|
||||
|
||||
updateTimer();
|
||||
|
||||
|
||||
if (watchStop && !Recording.isPlaying()) {
|
||||
watchStop = false;
|
||||
toolBar.setAlpha(ALPHA_ON, recordIcon);
|
||||
|
|
Loading…
Reference in a new issue