Fix recording GIF still displaying when reopen tablet to stop recording

This commit is contained in:
David Rowe 2017-04-16 12:57:37 +12:00
parent 15128faa49
commit 7dcda47f95
2 changed files with 75 additions and 59 deletions

View file

@ -176,10 +176,13 @@ function onScriptEventReceived(data) {
elFinishOnOpen.checked = message.value; elFinishOnOpen.checked = message.value;
break; break;
case START_RECORDING_ACTION: case START_RECORDING_ACTION:
isRecording = message.value; isRecording = true;
if (isRecording) { elRecordButton.classList.add("pressed");
elRecordButton.classList.add("pressed"); updateSpinner();
} break;
case STOP_RECORDING_ACTION:
isRecording = false;
elRecordButton.classList.remove("pressed");
updateSpinner(); updateSpinner();
break; break;
case RECORDINGS_BEING_PLAYED_ACTION: case RECORDINGS_BEING_PLAYED_ACTION:

View file

@ -413,61 +413,17 @@
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar"))); || (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar")));
} }
function onWebEventReceived(data) { function updateRecordingStatus(isRecording) {
var message = JSON.parse(data); if (isRecording) {
if (message.type === EVENT_BRIDGE_TYPE) { tablet.emitScriptEvent(JSON.stringify({
switch (message.action) { type: EVENT_BRIDGE_TYPE,
case BODY_LOADED_ACTION: action: START_RECORDING_ACTION
// Dialog's ready; initialize its state. }));
tablet.emitScriptEvent(JSON.stringify({ } else {
type: EVENT_BRIDGE_TYPE, tablet.emitScriptEvent(JSON.stringify({
action: USING_TOOLBAR_ACTION, type: EVENT_BRIDGE_TYPE,
value: isUsingToolbar() action: STOP_RECORDING_ACTION
})); }));
tablet.emitScriptEvent(JSON.stringify({
type: EVENT_BRIDGE_TYPE,
action: FINISH_ON_OPEN_ACTION,
value: isFinishOnOpen
}));
tablet.emitScriptEvent(JSON.stringify({
type: EVENT_BRIDGE_TYPE,
action: NUMBER_OF_PLAYERS_ACTION,
value: Player.numberOfPlayers()
}));
tablet.emitScriptEvent(JSON.stringify({
type: EVENT_BRIDGE_TYPE,
action: START_RECORDING_ACTION,
value: !Recorder.isIdle()
}));
break;
case STOP_PLAYING_RECORDING_ACTION:
// Stop the specified player.
Player.stopPlayingRecording(message.value);
break;
case LOAD_RECORDING_ACTION:
// User wants to select an ATP recording to play.
log("TODO: Open dialog for user to select ATP recording to play");
break;
case START_RECORDING_ACTION:
// Start making a recording.
if (Recorder.isIdle()) {
Recorder.startCountdown();
}
break;
case STOP_RECORDING_ACTION:
// Cancel or finish a recording.
if (Recorder.isCountingDown()) {
Recorder.cancelCountdown();
} else if (Recorder.isRecording()) {
Recorder.finishRecording();
}
break;
case FINISH_ON_OPEN_ACTION:
// Set behavior on dialog open.
isFinishOnOpen = message.value;
Settings.setValue(SETTINGS_FINISH_ON_OPEN, isFinishOnOpen);
break;
}
} }
} }
@ -501,6 +457,60 @@
return isFinishOnOpen; return isFinishOnOpen;
} }
function onWebEventReceived(data) {
var message = JSON.parse(data);
if (message.type === EVENT_BRIDGE_TYPE) {
switch (message.action) {
case BODY_LOADED_ACTION:
// Dialog's ready; initialize its state.
tablet.emitScriptEvent(JSON.stringify({
type: EVENT_BRIDGE_TYPE,
action: USING_TOOLBAR_ACTION,
value: isUsingToolbar()
}));
tablet.emitScriptEvent(JSON.stringify({
type: EVENT_BRIDGE_TYPE,
action: FINISH_ON_OPEN_ACTION,
value: isFinishOnOpen
}));
tablet.emitScriptEvent(JSON.stringify({
type: EVENT_BRIDGE_TYPE,
action: NUMBER_OF_PLAYERS_ACTION,
value: Player.numberOfPlayers()
}));
updateRecordingStatus(!Recorder.isIdle());
break;
case STOP_PLAYING_RECORDING_ACTION:
// Stop the specified player.
Player.stopPlayingRecording(message.value);
break;
case LOAD_RECORDING_ACTION:
// User wants to select an ATP recording to play.
log("TODO: Open dialog for user to select ATP recording to play");
break;
case START_RECORDING_ACTION:
// Start making a recording.
if (Recorder.isIdle()) {
Recorder.startCountdown();
}
break;
case STOP_RECORDING_ACTION:
// Cancel or finish a recording.
if (Recorder.isCountingDown()) {
Recorder.cancelCountdown();
} else if (Recorder.isRecording()) {
Recorder.finishRecording();
}
break;
case FINISH_ON_OPEN_ACTION:
// Set behavior on dialog open.
isFinishOnOpen = message.value;
Settings.setValue(SETTINGS_FINISH_ON_OPEN, isFinishOnOpen);
break;
}
}
}
function setUp() { function setUp() {
isFinishOnOpen = Settings.getValue(SETTINGS_FINISH_ON_OPEN) === true; isFinishOnOpen = Settings.getValue(SETTINGS_FINISH_ON_OPEN) === true;
tablet.webEventReceived.connect(onWebEventReceived); tablet.webEventReceived.connect(onWebEventReceived);
@ -512,6 +522,7 @@
return { return {
updatePlayerDetails: updatePlayerDetails, updatePlayerDetails: updatePlayerDetails,
updateRecordingStatus: updateRecordingStatus,
finishOnOpen: finishOnOpen, finishOnOpen: finishOnOpen,
setUp: setUp, setUp: setUp,
tearDown: tearDown tearDown: tearDown
@ -530,6 +541,7 @@
} else if (Recorder.isRecording()) { } else if (Recorder.isRecording()) {
Recorder.finishRecording(); Recorder.finishRecording();
} }
Dialog.updateRecordingStatus(false);
} }
isDialogDisplayed = true; isDialogDisplayed = true;
} else { } else {
@ -547,6 +559,7 @@
} else if (Recorder.isRecording()) { } else if (Recorder.isRecording()) {
Recorder.finishRecording(); Recorder.finishRecording();
} }
Dialog.updateRecordingStatus(false);
} }
} }