JasonLG1979 / gnome-shell-extension-mpris-indicator-button

A full featured MPRIS indicator button extension for GNOME Shell 3.38+
https://extensions.gnome.org/extension/1379/mpris-indicator-button/
GNU General Public License v3.0
159 stars 21 forks source link

When using in concert with GSConnect MPRIS indicator sets the volume to maximum. #41

Closed rohmishra closed 4 years ago

rohmishra commented 4 years ago

Describe the bug

When GSConnect is setup and you have a music already playing and you either power on your device or resume, MPRIS plugin sets the volume at full causing audio to unexpectedly rise on mobile phone.

Steps To Reproduce:

(Requires GSConnect to be configured)

  1. Play music on phone with volume less than full.
  2. Turn on/resume your computer.
  3. The volume rises to full on mobile phone once MPRIS indicator loads

Expected behavior

MPRIS plugin should show the actual volume set instead of increasing it to full by default.

Logs

Jun 24 13:36:15 stormstar systemd[1496]: Started Forward bluetooth midi controls via mpris2 so they.
                                             _getIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1911:45
                                             _getSymbolicIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1901:21
                                             refreshIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1547:26
                                             _updateMprisProps@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1708:18
                                             _finish_init@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1659:14
                                             _init@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1388:14
                                             _addPlayer/</<@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:447:29
                                             onProxyReady@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:268:17
                                             makeProxy/<@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:171:21
                                             _getIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1911:45
                                             _getSymbolicIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1901:21
                                             refreshIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1547:26
                                             _updateMprisProps@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1708:18
                                             _finish_init/<@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1639:18
                                             _getIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1911:45
                                             _getSymbolicIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1901:21
                                             refreshIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1547:26
                                             _updateMprisProps@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1708:18
                                             _finish_init/<@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1639:18
                                             _getIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1911:45
                                             _getSymbolicIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1901:21
                                             refreshIcon@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1547:26
                                             _updateMprisProps@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1708:18
                                             _finish_init@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1659:14
                                             _init@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:1388:14
                                             _addPlayer/</<@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:447:29
                                             onProxyReady@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:268:17
                                             makeProxy/<@/home/rmishra/.local/share/gnome-shell/extensions/mprisindicatorbutton@JasonLG1979.github.io/dbus.js:171:21
                                                                        "type": "kdeconnect.mpris",
                                                                        "type": "kdeconnect.mpris",
                                                                        "type": "kdeconnect.mpris.request",
                                                                        "type": "kdeconnect.mpris",
                                                                        "type": "kdeconnect.mpris",
                                                                        "type": "kdeconnect.mpris",

(the type kdeconnect lines are GSConnect) (GSConnect gets its volume data from the phone , the last line)

Jun 24 13:46:34 org.gnome.Shell.Extensions.GSConnect[1816]: [/service/protocol/core.js:receive/<:298]: winterbell: {
                                                              "id": 1593020793537,
                                                              "type": "kdeconnect.mpris",
                                                              "body": {
                                                                "player": "YouTube Music",
                                                                "nowPlaying": "Starley - Call on Me (Ryan Riback Remix)",
                                                                "title": "Call on Me (Ryan Riback Remix)",
                                                                "artist": "Starley",
                                                                "album": "Call on Me (Remixes)",
                                                                "isPlaying": true,
                                                                "pos": 49800,
                                                                "length": 222000,
                                                                "canPlay": true,
                                                                "canPause": true,
                                                                "canGoPrevious": true,
                                                                "canGoNext": true,
                                                                "canSeek": true,
                                                                "volume": 44
                                                              }
                                                            }

System Details (please complete the following information):

Additional Notes:

rohmishra commented 4 years ago

Ok so my mistake, i did some more research and found that GSConnect starts MediaPlayer2 Player with 1.0 irrespective of volume set on phone even though it gets that data from KDE Connect.

This issue #23 may be why mpris-indicator sets the volume to full:

1st a little bit of background. Volume is a read/write MPRIS property. Unfortunately it's broken in at least a few players (Spotify for example) and there's no real good way to tell if it really works other than to poke the property and see if it causes the player to emit a property changed signal. Basically I read the property change it by +/-0.1 and then change it back to it's initial amount when the MPRIS interface shows up

GSConnect will transmit any changes to volume but doesn't correctly start with correct value set. I'll Close this issue and start a new one with GSConnect.

rohmishra commented 4 years ago

mpris indicator changing volume to get volume increases the volume to maximum for GSConnect Players.

https://github.com/andyholmes/gnome-shell-extension-gsconnect/releases/tag/v40 fixes the issue with volume not being read which means the volume values are correctly available.

JasonLG1979 commented 4 years ago

@rohmishra Is there a reason you reopened this issue?

rohmishra commented 4 years ago

With v40 (and above) GSConnect now reports the correct volume when Volume is read but when using with mpris-indicator, Volume is set to 1 or max Volume irrespective of current Volume. Disabling mpris-indicator and using D-Feet to check value for MediaPlayer2 Volume reports the correct Volume as set on device.

JasonLG1979 commented 4 years ago

Well for a split second when it creates the interface it must be reporting full volume. The code to poke the volume property is here:

https://github.com/JasonLG1979/gnome-shell-extension-mpris-indicator-button/blob/master/mprisindicatorbutton%40JasonLG1979.github.io/dbus.js#L1878-L1893

    _testVolume() {
        // This should cause a Volume props change signal
        // if the player's Volume prop works correctly,
        // which in turn should cause the volume slider to show itself.
        // Spotify's Volume prop is broken for example so the volume slider
        // remains hidden since it's pointless to show a widget that doesn't do anything...
        if (this._playerProxy.Volume) {
            let initialVolume = this._playerProxy.Volume || 0.0;
            this._playerProxy.Volume = initialVolume <= 0.0
                ? 0.1
                : initialVolume >= 1.0
                ? 0.9
                : Math.min(initialVolume - 0.1, 0.0);
            this._playerProxy.Volume = initialVolume;
        }
    }
JasonLG1979 commented 4 years ago

Yep sure does:

See:

https://github.com/andyholmes/gnome-shell-extension-gsconnect/blob/35dec85999b80bff2ed0424c5bc178bb159f51c3/src/service/plugins/mpris.js#L805-L809


    get Volume() {
        if (this._Volume === undefined)
            this._Volume = 1.0;

        return this._Volume;
    }

Not my bug.

JasonLG1979 commented 4 years ago

The solution would be to make sure all the properties where populated before the interface was put up instead of putting up an interface with yet undefined property values.