mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 01:03:38 +02:00
Stub new avatar recording script that records when tablet is hidden
This commit is contained in:
parent
384f404602
commit
d748068373
1 changed files with 87 additions and 0 deletions
87
scripts/system/record.js
Normal file
87
scripts/system/record.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
"use strict";
|
||||
|
||||
//
|
||||
// record.js
|
||||
//
|
||||
// Created by David Rowe on 5 Apr 2017.
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
(function () {
|
||||
|
||||
var APP_NAME = "RECORD",
|
||||
APP_ICON_INACTIVE = "icons/tablet-icons/edit-i.svg", // FIXME: Record icon.
|
||||
APP_ICON_ACTIVE = "icons/tablet-icons/edit-a.svg", // FIXME: Record icon.
|
||||
isRecordingEnabled = false,
|
||||
isRecording = false,
|
||||
tablet,
|
||||
button;
|
||||
|
||||
function startRecording() {
|
||||
isRecording = true;
|
||||
print("Start recording");
|
||||
}
|
||||
|
||||
function finishRecording() {
|
||||
isRecording = false;
|
||||
print("Finish recording");
|
||||
}
|
||||
|
||||
function abandonRecording() {
|
||||
isRecording = false;
|
||||
print("Abandon recording");
|
||||
}
|
||||
|
||||
function onTabletShownChanged() {
|
||||
if (tablet.tabletShown) {
|
||||
// Finish recording if is recording.
|
||||
if (isRecording) {
|
||||
finishRecording();
|
||||
button.editProperties({ isActive: isRecordingEnabled || isRecording });
|
||||
}
|
||||
} else {
|
||||
// Start recording if recording is enabled.
|
||||
if (isRecordingEnabled) {
|
||||
startRecording();
|
||||
button.editProperties({ isActive: isRecordingEnabled || isRecording });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
if (!tablet) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Tablet/toolbar button.
|
||||
button = tablet.addButton({
|
||||
icon: APP_ICON_INACTIVE,
|
||||
activeIcon: APP_ICON_ACTIVE,
|
||||
text: APP_NAME,
|
||||
isActive: isRecordingEnabled || isRecording
|
||||
});
|
||||
|
||||
// Track showing/hiding tablet.
|
||||
tablet.tabletShownChanged.connect(onTabletShownChanged);
|
||||
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
if (isRecording) {
|
||||
abandonRecording();
|
||||
}
|
||||
|
||||
if (!tablet) {
|
||||
return;
|
||||
}
|
||||
tablet.tabletShownChanged.disconnect(onTabletShownChanged);
|
||||
tablet.removeButton(button);
|
||||
}
|
||||
|
||||
setUp();
|
||||
Script.scriptEnding.connect(tearDown);
|
||||
}());
|
Loading…
Reference in a new issue