Skip to content

Commit

Permalink
#141 Harden PlayNotificationTwo against some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
theimo1221 committed Aug 19, 2021
1 parent a6346f2 commit 3ae9ca9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -69,4 +69,7 @@ src/services/.generated
docs-automatic/
docs/_site/
docs/.sass-cache/
docs/vendor/
docs/vendor/

# Exclude Webstorm
.idea/
14 changes: 12 additions & 2 deletions src/sonos-device.ts
Expand Up @@ -1379,7 +1379,15 @@ export default class SonosDevice extends SonosDeviceBase {
this.notificationQueue.volumeChanged = false;
}

await this.AVTransportService.SetAVTransportURI({ InstanceID: 0, CurrentURI: originalMediaInfo.CurrentURI, CurrentURIMetaData: originalMediaInfo.CurrentURIMetaData });
await this.AVTransportService.SetAVTransportURI(
{
InstanceID: 0,
CurrentURI: originalMediaInfo.CurrentURI,
CurrentURIMetaData: originalMediaInfo.CurrentURIMetaData,
},
).catch((err) => {
this.debug('Error settingAVTransportURI, but this shouldn\'t stop the queue: %o', err);
});
if (options.delayMs !== undefined) await AsyncHelper.Delay(options.delayMs);

if (originalPositionInfo.Track > 1 && originalMediaInfo.NrTracks > 1) {
Expand All @@ -1399,7 +1407,9 @@ export default class SonosDevice extends SonosDeviceBase {
}

if (originalState === TransportState.Playing || originalState === TransportState.Transitioning) {
await this.AVTransportService.Play({ InstanceID: 0, Speed: '1' });
await this.AVTransportService.Play({ InstanceID: 0, Speed: '1' }).catch((err) => {
this.debug('Reverting back track time failed, happens for some music services (radio or stream). %o', err);
});
}
}

Expand Down

0 comments on commit 3ae9ca9

Please sign in to comment.