mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 05:23:33 +02:00
Start/cancel/finish recording logic
This commit is contained in:
parent
1ddae1c61a
commit
ce32f1704e
1 changed files with 77 additions and 8 deletions
|
@ -18,12 +18,79 @@
|
||||||
SHORTCUT_KEY = "r", // Alt modifier is assumed.
|
SHORTCUT_KEY = "r", // Alt modifier is assumed.
|
||||||
tablet,
|
tablet,
|
||||||
button,
|
button,
|
||||||
isRecording = false;
|
|
||||||
|
Recorder;
|
||||||
|
|
||||||
|
Recorder = (function () {
|
||||||
|
var IDLE = 0,
|
||||||
|
COUNTING_DOWN = 1,
|
||||||
|
RECORDING = 2,
|
||||||
|
recordingState = IDLE;
|
||||||
|
|
||||||
|
function isRecording() {
|
||||||
|
return recordingState === COUNTING_DOWN || recordingState === RECORDING;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startRecording() {
|
||||||
|
|
||||||
|
if (recordingState !== IDLE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
recordingState = COUNTING_DOWN;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelRecording() {
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
recordingState = IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishRecording() {
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
recordingState = IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopRecording() {
|
||||||
|
if (recordingState === COUNTING_DOWN) {
|
||||||
|
cancelRecording();
|
||||||
|
} else {
|
||||||
|
finishRecording();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function tearDown() {
|
||||||
|
if (recordingState !== IDLE) {
|
||||||
|
cancelRecording();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isRecording: isRecording,
|
||||||
|
startRecording: startRecording,
|
||||||
|
stopRecording: stopRecording,
|
||||||
|
setUp: setUp,
|
||||||
|
tearDown: tearDown
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
|
||||||
function toggleRecording() {
|
function toggleRecording() {
|
||||||
isRecording = !isRecording;
|
if (Recorder.isRecording()) {
|
||||||
button.editProperties({ isActive: isRecording });
|
Recorder.stopRecording();
|
||||||
// TODO: Start/cancel/finish recording.
|
} else {
|
||||||
|
Recorder.startRecording();
|
||||||
|
}
|
||||||
|
button.editProperties({ isActive: Recorder.isRecording() });
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyPressEvent(event) {
|
function onKeyPressEvent(event) {
|
||||||
|
@ -42,6 +109,8 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Recorder.setUp();
|
||||||
|
|
||||||
// Tablet/toolbar button.
|
// Tablet/toolbar button.
|
||||||
button = tablet.addButton({
|
button = tablet.addButton({
|
||||||
icon: APP_ICON_INACTIVE,
|
icon: APP_ICON_INACTIVE,
|
||||||
|
@ -57,9 +126,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
if (isRecording) {
|
|
||||||
// TODO: Cancel recording.
|
Controller.keyPressEvent.disconnect(onKeyPressEvent);
|
||||||
}
|
|
||||||
|
Recorder.tearDown();
|
||||||
|
|
||||||
if (!tablet) {
|
if (!tablet) {
|
||||||
return;
|
return;
|
||||||
|
@ -73,7 +143,6 @@
|
||||||
|
|
||||||
tablet = null;
|
tablet = null;
|
||||||
|
|
||||||
Controller.keyPressEvent.disconnect(onKeyPressEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setUp();
|
setUp();
|
||||||
|
|
Loading…
Reference in a new issue