Add: Workaround for CORS error on playMedia

pull/17/head
Juraj Nyíri 3 years ago
parent 532a217981
commit 480b5ccdc6

@ -18977,9 +18977,22 @@ class PlayController {
throw Error('Defined plexPlayer is currently not available for playback.'); throw Error('Defined plexPlayer is currently not available for playback.');
} }
else { else {
// if we caught CORS error, try to use workaround. Todo: figure out why is the CORS issue happening
try {
await this.hass.callService('rest_command', 'pmha_playmedia', {
// eslint-disable-next-line @typescript-eslint/camelcase
url,
// eslint-disable-next-line @typescript-eslint/camelcase
target_client_identifier: machineID,
// eslint-disable-next-line @typescript-eslint/camelcase
client_identifier: 'PlexMeetsHomeAssistant'
});
}
catch (homeAssistantErr) {
throw err; throw err;
} }
} }
}
}; };
this.playViaKodi = async (entityName, data, type) => { this.playViaKodi = async (entityName, data, type) => {
if (type === 'movie') { if (type === 'movie') {

@ -185,9 +185,21 @@ class PlayController {
if (_.includes(err.message, '404')) { if (_.includes(err.message, '404')) {
throw Error('Defined plexPlayer is currently not available for playback.'); throw Error('Defined plexPlayer is currently not available for playback.');
} else { } else {
// if we caught CORS error, try to use workaround. Todo: figure out why is the CORS issue happening
try {
await this.hass.callService('rest_command', 'pmha_playmedia', {
// eslint-disable-next-line @typescript-eslint/camelcase
url,
// eslint-disable-next-line @typescript-eslint/camelcase
target_client_identifier: machineID,
// eslint-disable-next-line @typescript-eslint/camelcase
client_identifier: 'PlexMeetsHomeAssistant'
});
} catch (homeAssistantErr) {
throw err; throw err;
} }
} }
}
}; };
private playViaKodi = async (entityName: string, data: Record<string, any>, type: string): Promise<void> => { private playViaKodi = async (entityName: string, data: Record<string, any>, type: string): Promise<void> => {

Loading…
Cancel
Save