coordinator.play();
} catch (IllegalStateException e) {
logger.debug("Cannot play URI ({})", e.getMessage());
+ } catch (InterruptedException e) {
+ logger.debug("Play URI interrupted ({})", e.getMessage());
+ Thread.currentThread().interrupt();
}
}
}
notificationLock.notify();
}
} catch (IllegalStateException e) {
- logger.debug("Cannot play sound ({})", e.getMessage());
+ logger.debug("Cannot play notification sound ({})", e.getMessage());
+ } catch (InterruptedException e) {
+ logger.debug("Play notification sound interrupted ({})", e.getMessage());
+ Thread.currentThread().interrupt();
}
}
}
* @param currentStreamURI - the currently loaded stream's URI
* @param notificationURL - the notification url in the format of //host/folder/filename.mp3
* @param coordinator - {@link ZonePlayerHandler} coordinator for the SONOS device(s)
+ * @throws InterruptedException
*/
private void handleRadioStream(@Nullable String currentStreamURI, Command notificationURL,
- ZonePlayerHandler coordinator) {
+ ZonePlayerHandler coordinator) throws InterruptedException {
String nextAction = coordinator.getTransportState();
SonosMetaData track = coordinator.getTrackMetadata();
SonosMetaData currentUriMetaData = coordinator.getCurrentURIMetadata();
* @param currentLineInURI - the currently loaded line-in URI
* @param notificationURL - the notification url in the format of //host/folder/filename.mp3
* @param coordinator - {@link ZonePlayerHandler} coordinator for the SONOS device(s)
+ * @throws InterruptedException
*/
- private void handleLineIn(@Nullable String currentLineInURI, Command notificationURL,
- ZonePlayerHandler coordinator) {
+ private void handleLineIn(@Nullable String currentLineInURI, Command notificationURL, ZonePlayerHandler coordinator)
+ throws InterruptedException {
logger.debug("Handling notification while sound from line-in was being played");
String nextAction = coordinator.getTransportState();
* @param currentQueueURI - the currently loaded queue URI
* @param notificationURL - the notification url in the format of //host/folder/filename.mp3
* @param coordinator - {@link ZonePlayerHandler} coordinator for the SONOS device(s)
+ * @throws InterruptedException
*/
private void handleSharedQueue(@Nullable String currentQueueURI, Command notificationURL,
- ZonePlayerHandler coordinator) {
+ ZonePlayerHandler coordinator) throws InterruptedException {
String nextAction = coordinator.getTransportState();
String trackPosition = coordinator.getRefreshedPosition();
long currentTrackNumber = coordinator.getRefreshedCurrenTrackNr();
*
* @param notificationURL - the notification url in the format of //host/folder/filename.mp3
* @param coordinator - {@link ZonePlayerHandler} coordinator for the SONOS device(s)
+ * @throws InterruptedException
*/
- private void handleNotificationSound(Command notificationURL, ZonePlayerHandler coordinator) {
+ private void handleNotificationSound(Command notificationURL, ZonePlayerHandler coordinator)
+ throws InterruptedException {
boolean sourceStoppable = !isPlayingOpticalLineIn(coordinator.getCurrentURI());
String originalVolume = (isAdHocGroup() || isStandalonePlayer()) ? getVolume() : coordinator.getVolume();
if (sourceStoppable) {
coordinator.removeRangeOfTracksFromQueue(new StringType(Long.toString(notificationPosition) + ",1"));
}
- private void restoreLastTransportState(ZonePlayerHandler coordinator, @Nullable String nextAction) {
+ private void restoreLastTransportState(ZonePlayerHandler coordinator, @Nullable String nextAction)
+ throws InterruptedException {
if (nextAction != null) {
switch (nextAction) {
case STATE_PLAYING:
*
* @param notificationURL - the notification url in the format of //host/folder/filename.mp3
* @param coordinator - {@link ZonePlayerHandler} coordinator for the SONOS device(s)
+ * @throws InterruptedException
*/
- private void handleEmptyQueue(Command notificationURL, ZonePlayerHandler coordinator) {
+ private void handleEmptyQueue(Command notificationURL, ZonePlayerHandler coordinator) throws InterruptedException {
String originalVolume = coordinator.getVolume();
coordinator.applyNotificationSoundVolume();
coordinator.playURI(notificationURL);
setNotificationSoundVolume(getNotificationSoundVolume());
}
- private void waitForFinishedNotification() {
+ private void waitForFinishedNotification() throws InterruptedException {
waitForTransportState(STATE_PLAYING);
// check Sonos state events to determine the end of the notification sound
String notificationTitle = getCurrentTitle();
long playstart = System.currentTimeMillis();
while (System.currentTimeMillis() - playstart < (long) configuration.notificationTimeout * 1000) {
- try {
- Thread.sleep(50);
- String currentTitle = getCurrentTitle();
- if ((notificationTitle == null && currentTitle != null)
- || (notificationTitle != null && !notificationTitle.equals(currentTitle))
- || !STATE_PLAYING.equals(getTransportState())) {
- break;
- }
- } catch (InterruptedException e) {
- logger.debug("InterruptedException during playing a notification sound");
+ Thread.sleep(50);
+ String currentTitle = getCurrentTitle();
+ if ((notificationTitle == null && currentTitle != null)
+ || (notificationTitle != null && !notificationTitle.equals(currentTitle))
+ || !STATE_PLAYING.equals(getTransportState())) {
+ break;
}
}
}
- private void waitForTransportState(String state) {
+ private void waitForTransportState(String state) throws InterruptedException {
if (getTransportState() != null) {
long start = System.currentTimeMillis();
while (!state.equals(getTransportState())) {
- try {
- Thread.sleep(50);
- if (System.currentTimeMillis() - start > (long) configuration.notificationTimeout * 1000) {
- break;
- }
- } catch (InterruptedException e) {
- logger.debug("InterruptedException during playing a notification sound");
+ Thread.sleep(50);
+ if (System.currentTimeMillis() - start > (long) configuration.notificationTimeout * 1000) {
+ break;
}
}
}
}
- private void waitForNotTransportState(String state) {
+ private void waitForNotTransportState(String state) throws InterruptedException {
if (getTransportState() != null) {
long start = System.currentTimeMillis();
while (state.equals(getTransportState())) {
- try {
- Thread.sleep(50);
- if (System.currentTimeMillis() - start > (long) configuration.notificationTimeout * 1000) {
- break;
- }
- } catch (InterruptedException e) {
- logger.debug("InterruptedException during playing a notification sound");
+ Thread.sleep(50);
+ if (System.currentTimeMillis() - start > (long) configuration.notificationTimeout * 1000) {
+ break;
}
}
}