mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-26 09:25:56 +02:00
Inform user when an AC error prevents a recording from playing
This commit is contained in:
parent
42aacb07ff
commit
acd71caae2
2 changed files with 41 additions and 17 deletions
|
@ -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,12 +70,14 @@
|
||||||
|
|
||||||
if (sender !== scriptUUID) {
|
if (sender !== scriptUUID) {
|
||||||
message = JSON.parse(message);
|
message = JSON.parse(message);
|
||||||
index = otherPlayersPlaying.indexOf(message.entity);
|
if (message.playing !== undefined) {
|
||||||
if (index !== -1) {
|
index = otherPlayersPlaying.indexOf(message.entity);
|
||||||
otherPlayersPlayingCounts[index] += 1;
|
if (index !== -1) {
|
||||||
} else {
|
otherPlayersPlayingCounts[index] += 1;
|
||||||
otherPlayersPlaying.push(message.entity);
|
} else {
|
||||||
otherPlayersPlayingCounts.push(1);
|
otherPlayersPlaying.push(message.entity);
|
||||||
|
otherPlayersPlayingCounts.push(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,15 +351,19 @@
|
||||||
|
|
||||||
message = JSON.parse(message);
|
message = JSON.parse(message);
|
||||||
|
|
||||||
index = playerIDs.indexOf(sender);
|
if (message.command === RECORDER_COMMAND_ERROR) {
|
||||||
if (index === -1) {
|
error(message.message);
|
||||||
index = playerIDs.length;
|
} else {
|
||||||
playerIDs[index] = sender;
|
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() {
|
function reset() {
|
||||||
|
|
Loading…
Reference in a new issue