overte/script-archive/acScripts/PlayRecordingOnAC.js

56 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2014-08-26 18:24:09 -07:00
//
// PlayRecordingOnAC.js
// examples
//
// Created by Clément Brisset on 8/24/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var recordingFile = "http://your.recording.url";
2014-08-26 18:24:09 -07:00
var playFromCurrentLocation = true;
var loop = true;
2014-08-26 18:24:09 -07:00
// Set position here if playFromCurrentLocation is true
Avatar.position = { x:1, y: 1, z: 1 };
2014-08-29 14:25:05 -07:00
Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0);
Avatar.scale = 1.0;
2014-08-26 18:24:09 -07:00
Agent.isAvatar = true;
2015-08-31 16:53:30 +02:00
// Disable the privacy bubble
Users.disableIgnoreRadius();
Recording.loadRecording(recordingFile, function(success) {
if (success) {
Script.update.connect(update);
2017-04-14 11:53:11 -07:00
} else {
print("Failed to load recording from " + recordingFile);
}
});
2014-08-26 18:24:09 -07:00
count = 300; // This is necessary to wait for the audio mixer to connect
function update(event) {
2015-08-31 16:53:30 +02:00
if (count > 0) {
count--;
return;
}
if (count == 0) {
Recording.setPlayFromCurrentLocation(playFromCurrentLocation);
Recording.setPlayerLoop(loop);
Recording.setPlayerUseDisplayName(true);
Recording.setPlayerUseAttachments(true);
Recording.setPlayerUseHeadModel(false);
Recording.setPlayerUseSkeletonModel(true);
Recording.startPlaying();
2015-08-31 16:53:30 +02:00
Vec3.print("Playing from ", Avatar.position);
count--;
}
if (!Recording.isPlaying()) {
2015-08-31 16:53:30 +02:00
Script.update.disconnect(update);
}
2014-08-26 18:24:09 -07:00
}