Merge pull request #4746 from Sky-High/cast-with-localhost-server
This commit is contained in:
commit
c506d0b753
1 changed files with 17 additions and 8 deletions
|
@ -27,13 +27,11 @@ function sendConnectionResult(isOk) {
|
||||||
if (resolve) {
|
if (resolve) {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
} else {
|
} else if (reject) {
|
||||||
if (reject) {
|
|
||||||
reject();
|
reject();
|
||||||
} else {
|
} else {
|
||||||
playbackManager.removeActivePlayer(PlayerName);
|
playbackManager.removeActivePlayer(PlayerName);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,7 +292,7 @@ class CastPlayer {
|
||||||
loadMedia(options, command) {
|
loadMedia(options, command) {
|
||||||
if (!this.session) {
|
if (!this.session) {
|
||||||
console.debug('no session');
|
console.debug('no session');
|
||||||
return Promise.reject();
|
return Promise.reject(new Error('no session'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert items to smaller stubs to send minimal amount of information
|
// convert items to smaller stubs to send minimal amount of information
|
||||||
|
@ -335,16 +333,27 @@ class CastPlayer {
|
||||||
apiClient = ServerConnections.currentApiClient();
|
apiClient = ServerConnections.currentApiClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If serverAddress is localhost,this address can not be used for the cast receiver device.
|
||||||
|
* Use the local address (ULA, Unique Local Address) in that case.
|
||||||
|
*/
|
||||||
|
const serverAddress = apiClient.serverAddress();
|
||||||
|
// eslint-disable-next-line compat/compat
|
||||||
|
const hostname = (new URL(serverAddress)).hostname;
|
||||||
|
const isLocalhost = hostname === 'localhost' || hostname.startsWith('127.') || hostname === '[::1]';
|
||||||
|
const serverLocalAddress = isLocalhost ? apiClient.serverInfo().LocalAddress : serverAddress;
|
||||||
|
|
||||||
message = Object.assign(message, {
|
message = Object.assign(message, {
|
||||||
userId: apiClient.getCurrentUserId(),
|
userId: apiClient.getCurrentUserId(),
|
||||||
deviceId: apiClient.deviceId(),
|
deviceId: apiClient.deviceId(),
|
||||||
accessToken: apiClient.accessToken(),
|
accessToken: apiClient.accessToken(),
|
||||||
serverAddress: apiClient.serverAddress(),
|
serverAddress: serverLocalAddress,
|
||||||
serverId: apiClient.serverId(),
|
serverId: apiClient.serverId(),
|
||||||
serverVersion: apiClient.serverVersion(),
|
serverVersion: apiClient.serverVersion(),
|
||||||
receiverName: receiverName
|
receiverName: receiverName
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.debug('[chromecastPlayer] message{' + message.command + '; ' + serverAddress + ' -> ' + serverLocalAddress + '}');
|
||||||
|
|
||||||
const bitrateSetting = appSettings.maxChromecastBitrate();
|
const bitrateSetting = appSettings.maxChromecastBitrate();
|
||||||
if (bitrateSetting) {
|
if (bitrateSetting) {
|
||||||
message.maxBitrate = bitrateSetting;
|
message.maxBitrate = bitrateSetting;
|
||||||
|
@ -592,7 +601,7 @@ class ChromecastPlayer {
|
||||||
currentResolve = null;
|
currentResolve = null;
|
||||||
currentReject = null;
|
currentReject = null;
|
||||||
|
|
||||||
return Promise.reject();
|
return Promise.reject(new Error('tryPair failed'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue