Skip to content

Commit

Permalink
feat(chromecast): Catch buffering media
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Jan 25, 2024
1 parent e855a3d commit 5103cf1
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions src/backend/sources/ChromecastSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export class ChromecastSource extends MemorySource {
this.config.data = {
...data,
useAutoDiscovery: ad,
useAvahi
useAvahi,
interval: 2
}

}
Expand Down Expand Up @@ -497,9 +498,37 @@ export class ChromecastSource extends MemorySource {
//v.applications.delete(application.transportId);
// TODO count timeouts before setting app as stale
continue;
} else {
throw e;
}

const validationError = findCauseByReference(e, ContextualValidationError);
if (validationError && validationError.data !== undefined) {
const {
status = []
} = validationError.data as Record<string, any>;
if(status[0] !== undefined) {
const {
media: {
streamType = undefined
} = {}
} = status[0] || {};
if(streamType === 'BUFFERED') {
let maybePlay: PlayObject | undefined;
try {
maybePlay = ChromecastSource.formatPlayObj(status[0]);
} catch (e) {
// its fine just do error without play string
}
application.logger.verbose(`Skipping status for ${maybePlay !== undefined ? buildTrackString(maybePlay) : 'unknown media'} because it is buffering.`);
if (this.config.options.logPayload) {
application.logger.debug(`Media Status Payload:\n ${status[0] === undefined || status[0] === null ? 'undefined' : JSON.stringify(status[0])}`);
}
continue;
}
}
application.logger.warn(JSON.stringify(validationError.data));
}

throw e;
}

if (this.config.options.logPayload) {
Expand Down Expand Up @@ -604,7 +633,7 @@ export class ChromecastSource extends MemorySource {
albumName,
album: albumNorm
} = {}
}
} = {}
} = obj;

let artists: string[] = [],
Expand Down

0 comments on commit 5103cf1

Please sign in to comment.