coderholic / pyradio

Curses based internet radio player
www.coderholic.com/pyradio
MIT License
956 stars 129 forks source link

Suggestion - MPRIS #166

Open elkrien opened 2 years ago

elkrien commented 2 years ago

Hi there! Congratulations on this project.

Do you plan on adding MPRIS support so it can be controlled with media keys on Linux?

s-n-g commented 2 years ago

Hi @elkrien

This is something that has already been requested in the past, so yes, I will eventually look into it... But it may take some time... :wink:

jediafr commented 1 year ago

FYI Mpris can be added to mpv through https://github.com/hoyon/mpv-mpris. It works on my KDE widget , i can see pyradio title, length and act on volume through it.

One thing would be cool is that Pyradio constitutes a playlist with the searched radios so we could press next to change without having to recall pyradio window.

s-n-g commented 1 year ago

Hi @jediafr

I am aware of the mpv-mpris plugin; vlc also has mpris enabled, and even an mplayer mpris plugin exists.

It's not that I haven't looked into it, but...

I have tried to use mpris-server with PyRadio, but I just cannot seem to get it to work as intended.

The problem is that in order for it to enter the DBus event loop (apparently that's the way it gets to send and receive signals), I have to use

from gi.repository import GLib

loop = GLib.MainLoop()
loop.run()

or similar code, running in a different thread.

And once I do that, the logger starts printing debug messages to the terminal, which actually breaks the TUI, and this happens even when debug is off (-d is not used).

This may be an absolutely fine and acceptable behavior for a GUI application, but for a TUI one, as PyRadio it's a no go.

Now, removing the logger would not be an option; I would not be able to continue the development without it, plus the Titles Logging feature depends on it...

I know this is too technical and all, but I put it up here so that if anyone can provide some help on how to go on with it, I would be grateful

leleobhz commented 4 months ago

@s-n-g

2 cents here: I dont think using mpv mpris support is the proper way to do this because some radios simply does not export anything on stream metadata, as next screenshot shows:

image

I would suggest to add a "third player" option python-mpv (https://github.com/jaseg/python-mpv) and use this to play and fetch metadata from stream - and if stream does not have any metadata, fullfull mpris data with stations.csv information (name and image).

That said, a little bridge with mpris-server and ptrhon-mpv metadata may help. Using python-mpv does not instantiate an entire mpv thread and allow mpv to be controlled from python instead a IPC socket. And also allow a better metadata handling.

About mpris-server, you posted GLib example, but the functional example at https://github.com/alexdelorenzo/mpris_server?tab=readme-ov-file#example does not use this kind of instancing. Is this right?

s-n-g commented 4 months ago

Thank you for the suggestion @leleobhz

I will look into this!