Inform user when an AC error prevents a recording from playing

This commit is contained in:
David Rowe 2017-05-12 14:53:38 +12:00
parent 42aacb07ff
commit acd71caae2
2 changed files with 41 additions and 17 deletions

View file

@ -14,6 +14,7 @@
var APP_NAME = "PLAYBACK", var APP_NAME = "PLAYBACK",
HIFI_RECORDER_CHANNEL = "HiFi-Recorder-Channel", HIFI_RECORDER_CHANNEL = "HiFi-Recorder-Channel",
RECORDER_COMMAND_ERROR = "error",
HIFI_PLAYER_CHANNEL = "HiFi-Player-Channel", HIFI_PLAYER_CHANNEL = "HiFi-Player-Channel",
PLAYER_COMMAND_PLAY = "play", PLAYER_COMMAND_PLAY = "play",
PLAYER_COMMAND_STOP = "stop", PLAYER_COMMAND_STOP = "stop",
@ -69,6 +70,7 @@
if (sender !== scriptUUID) { if (sender !== scriptUUID) {
message = JSON.parse(message); message = JSON.parse(message);
if (message.playing !== undefined) {
index = otherPlayersPlaying.indexOf(message.entity); index = otherPlayersPlaying.indexOf(message.entity);
if (index !== -1) { if (index !== -1) {
otherPlayersPlayingCounts[index] += 1; otherPlayersPlayingCounts[index] += 1;
@ -78,6 +80,7 @@
} }
} }
} }
}
function create(filename, position, orientation) { function create(filename, position, orientation) {
// Create a new persistence entity (even if already have one but that should never occur). // Create a new persistence entity (even if already have one but that should never occur).
@ -270,14 +273,26 @@
playRecording; playRecording;
function error(message) {
// Send error message to user.
Messages.sendMessage(HIFI_RECORDER_CHANNEL, JSON.stringify({
command: RECORDER_COMMAND_ERROR,
message: message
}));
}
function play(recording, position, orientation) { function play(recording, position, orientation) {
var errorMessage;
if (Entity.create(recording, position, orientation)) { if (Entity.create(recording, position, orientation)) {
log("Play recording " + recordingFilename); log("Play recording " + recording);
isPlayingRecording = true; isPlayingRecording = true;
recordingFilename = recording; recordingFilename = recording;
playRecording(recordingFilename, position, orientation); playRecording(recordingFilename, position, orientation);
} else { } else {
log("Could not play recording " + recordingFilename); errorMessage = "Could not play recording " + recording.slice(4); // Remove leading "atp:".
log(errorMessage);
error(errorMessage);
} }
} }
@ -299,6 +314,8 @@
playRecording = function (recording, position, orientation) { playRecording = function (recording, position, orientation) {
Recording.loadRecording(recording, function (success) { Recording.loadRecording(recording, function (success) {
var errorMessage;
if (success) { if (success) {
Users.disableIgnoreRadius(); Users.disableIgnoreRadius();
@ -321,7 +338,9 @@
UserActivityLogger.logAction("playRecordingAC_play_recording"); UserActivityLogger.logAction("playRecordingAC_play_recording");
} else { } else {
log("Failed to load recording " + recording); errorMessage = "Could not load recording " + recording.slice(4); // Remove leading "atp:".
log(errorMessage);
error(errorMessage);
autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_ERROR_INTERVAL); // Try again later. autoPlayTimer = Script.setTimeout(autoPlay, AUTOPLAY_ERROR_INTERVAL); // Try again later.
} }
}); });

View file

@ -269,6 +269,7 @@
Player = (function () { Player = (function () {
var HIFI_RECORDER_CHANNEL = "HiFi-Recorder-Channel", var HIFI_RECORDER_CHANNEL = "HiFi-Recorder-Channel",
RECORDER_COMMAND_ERROR = "error",
HIFI_PLAYER_CHANNEL = "HiFi-Player-Channel", HIFI_PLAYER_CHANNEL = "HiFi-Player-Channel",
PLAYER_COMMAND_PLAY = "play", PLAYER_COMMAND_PLAY = "play",
PLAYER_COMMAND_STOP = "stop", PLAYER_COMMAND_STOP = "stop",
@ -350,6 +351,9 @@
message = JSON.parse(message); message = JSON.parse(message);
if (message.command === RECORDER_COMMAND_ERROR) {
error(message.message);
} else {
index = playerIDs.indexOf(sender); index = playerIDs.indexOf(sender);
if (index === -1) { if (index === -1) {
index = playerIDs.length; index = playerIDs.length;
@ -360,6 +364,7 @@
playerTimestamps[index] = Date.now(); playerTimestamps[index] = Date.now();
Dialog.updatePlayerDetails(playerIsPlayings, playerRecordings, playerIDs); Dialog.updatePlayerDetails(playerIsPlayings, playerRecordings, playerIDs);
} }
}
function reset() { function reset() {
playerIDs = []; playerIDs = [];