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",
HIFI_RECORDER_CHANNEL = "HiFi-Recorder-Channel",
RECORDER_COMMAND_ERROR = "error",
HIFI_PLAYER_CHANNEL = "HiFi-Player-Channel",
PLAYER_COMMAND_PLAY = "play",
PLAYER_COMMAND_STOP = "stop",
@ -69,12 +70,14 @@
if (sender !== scriptUUID) {
message = JSON.parse(message);
index = otherPlayersPlaying.indexOf(message.entity);
if (index !== -1) {
otherPlayersPlayingCounts[index] += 1;
} else {
otherPlayersPlaying.push(message.entity);
otherPlayersPlayingCounts.push(1);
if (message.playing !== undefined) {
index = otherPlayersPlaying.indexOf(message.entity);
if (index !== -1) {
otherPlayersPlayingCounts[index] += 1;
} else {
otherPlayersPlaying.push(message.entity);
otherPlayersPlayingCounts.push(1);
}
}
}
}
@ -270,14 +273,26 @@
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) {
var errorMessage;
if (Entity.create(recording, position, orientation)) {
log("Play recording " + recordingFilename);
log("Play recording " + recording);
isPlayingRecording = true;
recordingFilename = recording;
playRecording(recordingFilename, position, orientation);
} 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) {
Recording.loadRecording(recording, function (success) {
var errorMessage;
if (success) {
Users.disableIgnoreRadius();
@ -321,7 +338,9 @@
UserActivityLogger.logAction("playRecordingAC_play_recording");
} 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.
}
});

View file

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