louis77 / tuner

GNU/Linux app to discover and play internet radio stations
GNU General Public License v3.0
195 stars 26 forks source link

Include 'Now Playing' info (D-Bus MPRIS) #72

Open Norimaki opened 3 years ago

Norimaki commented 3 years ago

Please consider including at least one field in the mpris metadata to indicate what is currently playing.

Something like .metadata["tuner.nowplaying"] (like vlc ["vlc.nowplaying"])

Although maybe it would be better to have:

"xesam: title" = player.nowplaying ("York - Farewell To The Moon) "xesam: artist" = station.title ("Amb2FM")

and not

"xesam: title" = "Tuner" "xesam: artist" = station.title

heldderarbeit commented 2 years ago

Hello, this is a feature I would love to see. Right now, the Wingpanel Sound Indicator panel is a bit empty (compared for example with the default Elementary music app):

Screenshot from 2021-11-20 03-46-28

I have no prior experience with Vala, but I hacked something together that - kinda - shows what could be a possible goal here:

Before

Screenshot from 2021-11-20 04-00-39

After

Screenshot from 2021-11-20 04-22-35

In DBusMediaPlayer.vala

public HashTable<string, Variant>? metadata {
   owned get {
      var table = new HashTable<string, Variant> (str_hash, str_equal);
      var playerController = Application.instance.player;
      var media_info = playerController.player.get_media_info();
      table.insert ("xesam:title", playerController.extract_title_from_stream(media_info));
      var station = Application.instance.player.station;
      if (station != null) {
         var station_title = station.title;
         var favicon_url = station.favicon_url;
         table.insert ("xesam:artist", get_simple_string_array (station_title));
         table.insert ("mpris:artUrl", favicon_url);
      } else {
         table.insert ("xesam:artist", get_simple_string_array (null));
      }
      return table;
   }
}

Now, the major problem with this construction is that song changes don't get reflected in the sound indicator area - The title is updated automatically in the main window of the app, but not outside of that. Does anyone know how to fix that? Screenshot from 2021-11-20 05-09-50

Norimaki commented 2 years ago

Hi, I have been working on mpris. You can see my progress here: https://github.com/Norimaki/tuner/tree/master-mpris-wip

It's not finished but it should be works.

Regarding Wingpanel: I'm developing under xfce with xfce4-pulseaudio-plugin but maybe it's related.

I also had problems. The main issue was the plugin expects to receive a Variant of type String (pulseaudio-mpris-player.c::player->title = g_strdup(g_variant_get_string(value, NULL));) but get_simple_string_array() does not send it.