pascalopitz / unoffical-sonos-controller-for-linux

An Electron based linux app for controlling your sonos system.
http://pascalopitz.github.io/unoffical-sonos-controller-for-linux/
MIT License
545 stars 49 forks source link

Added System Media Player Integration #166

Closed wapacro closed 2 years ago

wapacro commented 2 years ago

Hey @pascalopitz

Thank you for this awesome Sonos Controller for Linux! I only recently started using it myself on a daily basis and one thing that has long bothered me about the official Windows Sonos controller was the lack of integration into the operating system, so without further ado I wanted to take the chance and make this possible at least on Linux :wink:

Therefore, this pull request adds an MPRIS integration for the currently played song in the currently selected device/group. This allows among other things:

Here's how that could look like: image

Never worked with Electron and only indirectly with React, so very interested in your feedback and please let me know if you want me to adjust anything.

pascalopitz commented 2 years ago

@wapacro This is excellent work!

Testing it quickly, I can see that if there's no Song in the queue, I get "Unknown Artist", "Unknown song".

One more thought here: Streams might disable seek, next and so on. I can see from the mpris-service documentation, that there are properties for that available also. They should probably get mapped depending on the current track type.

wapacro commented 2 years ago

Many thanks for the inputs :slightly_smiling_face:

Testing it quickly, I can see that if there's no Song in the queue, I get "Unknown Artist", "Unknown song".

Indeed, missed that. Unfortunately, I can't find a way right now to close an MPRIS channel/player once it has been instantiated, but I have nevertheless delayed the initialization so that the player is not created until there is effectively something to display. Switching back and forth between devices with and without queue therefore still leads to the "Unknown song" problem; however, it no longer occurs at app startup if the automatically/initially selected device has no queue. See commit 0fb35be

One more thought here: Streams might disable seek, next and so on. I can see from the mpris-service documentation, that there are properties for that available also. They should probably get mapped depending on the current track type.

Great idea! The anyway (for now) not supported features like seeking are now statically disabled (cfbce46); "play", "next" and "previous" are dynamically de-/activated (15d5f14).

pascalopitz commented 2 years ago

New release published, v0.2.9