1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

when connected to chromecast make thehardware volume buttons change the chromecast device volume + fix volumeUp and columeDown missing var's

This commit is contained in:
Froghut 2019-04-02 09:43:49 +02:00
parent f6f51d79cc
commit 4baad878ac

View file

@ -220,7 +220,9 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
this.session = null;
this.deviceState = DEVICE_STATE.IDLE;
this.castPlayerState = PLAYER_STATE.IDLE;
document.removeEventListener("volumeupbutton", onVolumeUpKeyDown, false);
document.removeEventListener("volumedownbutton", onVolumeDownKeyDown, false);
//console.log('sessionUpdateListener: setting currentMediaSession to null');
this.currentMediaSession = null;
@ -258,6 +260,9 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
this.session.addMediaListener(this.sessionMediaListener.bind(this));
this.session.addUpdateListener(this.sessionUpdateListener.bind(this));
document.addEventListener("volumeupbutton", onVolumeUpKeyDown, false);
document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false);
events.trigger(this, 'connect');
this.sendMessage({
@ -266,6 +271,14 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
});
};
function onVolumeUpKeyDown() {
playbackManager.volumeUp();
}
function onVolumeDownKeyDown() {
playbackManager.volumeDown();
}
/**
* session update listener
*/
@ -305,6 +318,8 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
//console.log(message);
this.deviceState = DEVICE_STATE.IDLE;
this.castPlayerState = PLAYER_STATE.IDLE;
document.removeEventListener("volumeupbutton", onVolumeUpKeyDown, false);
document.removeEventListener("volumedownbutton", onVolumeDownKeyDown, false);
//console.log('onStopAppSuccess: setting currentMediaSession to null');
this.currentMediaSession = null;
@ -786,13 +801,13 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
});
};
ChromecastPlayer.prototype.volumeDown = function () {
vol = this._castPlayer.session.receiver.volume.level;
ChromecastPlayer.prototype.volumeDown = function () {
var vol = this._castPlayer.session.receiver.volume.level;
if (vol == null)
{
vol = 0.5;
}
vol -= 0.02;
vol -= 0.05;
vol = Math.max(vol, 0);
this._castPlayer.session.setReceiverVolumeLevel(vol);
@ -811,12 +826,12 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
};
ChromecastPlayer.prototype.volumeUp = function () {
vol = this._castPlayer.session.receiver.volume.level;
var vol = this._castPlayer.session.receiver.volume.level;
if (vol == null)
{
vol = 0.5;
}
vol += 0.02;
vol += 0.05;
vol = Math.min(vol, 1);
this._castPlayer.session.setReceiverVolumeLevel(vol);