From 732d8b5e26f0109643e424d38978622810a723c0 Mon Sep 17 00:00:00 2001 From: Froghut Date: Sun, 31 Mar 2019 12:05:54 +0200 Subject: [PATCH] When changing volume connected to chromecast change the device volume instead of the jellyfin-player volume --- src/components/chromecast/chromecastplayer.js | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/components/chromecast/chromecastplayer.js b/src/components/chromecast/chromecastplayer.js index d276bb4de2..cb63e9c4a8 100644 --- a/src/components/chromecast/chromecastplayer.js +++ b/src/components/chromecast/chromecastplayer.js @@ -779,12 +779,15 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', ' }); }; - ChromecastPlayer.prototype.volumeDown = function () { + ChromecastPlayer.prototype.volumeDown = function () { + vol = this._castPlayer.session.receiver.volume.level; + if (vol == null) + vol = 0.5; + vol -= 0.02; + vol = Math.max(vol, 0); + + this._castPlayer.session.setReceiverVolumeLevel(vol); - this._castPlayer.sendMessage({ - options: {}, - command: 'VolumeDown' - }); }; ChromecastPlayer.prototype.endSession = function () { @@ -799,24 +802,22 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', ' }; ChromecastPlayer.prototype.volumeUp = function () { + vol = this._castPlayer.session.receiver.volume.level; + if (vol == null) + vol = 0.5; + vol += 0.02; + vol = Math.min(vol, 1); - this._castPlayer.sendMessage({ - options: {}, - command: 'VolumeUp' - }); + this._castPlayer.session.setReceiverVolumeLevel(vol); }; ChromecastPlayer.prototype.setVolume = function (vol) { vol = Math.min(vol, 100); vol = Math.max(vol, 0); - - this._castPlayer.sendMessage({ - options: { - volume: vol - }, - command: 'SetVolume' - }); + vol = vol / 100; + + this._castPlayer.session.setReceiverVolumeLevel(vol); }; ChromecastPlayer.prototype.unpause = function () {