Merge pull request #5740 from dmitrylyzo/fix-tv-volume

Don't change volume if it is physically controlled
This commit is contained in:
Bill Thornton 2024-07-09 23:38:47 -04:00 committed by GitHub
commit e0a0c92b43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 6 deletions

View File

@ -33,6 +33,10 @@ function enableLocalPlaylistManagement(player) {
return player.isLocalPlayer;
}
function supportsPhysicalVolumeControl(player) {
return player.isLocalPlayer && appHost.supports('physicalvolumecontrol');
}
function bindToFullscreenChange(player) {
if (Screenfull.isEnabled) {
Screenfull.on('change', function () {
@ -1157,7 +1161,7 @@ class PlaybackManager {
self.setVolume = function (val, player) {
player = player || self._currentPlayer;
if (player) {
if (player && !supportsPhysicalVolumeControl(player)) {
player.setVolume(val);
}
};
@ -1165,15 +1169,17 @@ class PlaybackManager {
self.getVolume = function (player) {
player = player || self._currentPlayer;
if (player) {
if (player && !supportsPhysicalVolumeControl(player)) {
return player.getVolume();
}
return 1;
};
self.volumeUp = function (player) {
player = player || self._currentPlayer;
if (player) {
if (player && !supportsPhysicalVolumeControl(player)) {
player.volumeUp();
}
};
@ -1181,7 +1187,7 @@ class PlaybackManager {
self.volumeDown = function (player) {
player = player || self._currentPlayer;
if (player) {
if (player && !supportsPhysicalVolumeControl(player)) {
player.volumeDown();
}
};

View File

@ -263,7 +263,10 @@ class HtmlAudioPlayer {
document.body.appendChild(elem);
}
elem.volume = htmlMediaHelper.getSavedVolume();
// TODO: Move volume control to PlaybackManager. Player should just be a wrapper that translates commands into API calls.
if (!appHost.supports('physicalvolumecontrol')) {
elem.volume = htmlMediaHelper.getSavedVolume();
}
self._mediaElement = elem;

View File

@ -1584,7 +1584,11 @@ export class HtmlVideoPlayer {
playerDlg.innerHTML = html;
const videoElement = playerDlg.querySelector('video');
videoElement.volume = getSavedVolume();
// TODO: Move volume control to PlaybackManager. Player should just be a wrapper that translates commands into API calls.
if (!appHost.supports('physicalvolumecontrol')) {
videoElement.volume = getSavedVolume();
}
videoElement.addEventListener('timeupdate', this.onTimeUpdate);
videoElement.addEventListener('ended', this.onEnded);
videoElement.addEventListener('volumechange', this.onVolumeChange);