Add: Workaround for CORS error on playMedia

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

@ -18977,7 +18977,20 @@ class PlayController {
throw Error('Defined plexPlayer is currently not available for playback.');
}
else {
throw err;
// 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;
}
}
}
};

@ -185,7 +185,19 @@ class PlayController {
if (_.includes(err.message, '404')) {
throw Error('Defined plexPlayer is currently not available for playback.');
} else {
throw err;
// 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;
}
}
}
};

Loading…
Cancel
Save