DBus/MPRIS2: GnomeMusic should send "Stopped" message when audio-track ends

Bug #1819198 reported by moma
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnome-music (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Re-hi,

GnomeMusic (via Dbus/MPRIS2) does not send "Stopped" message even audio-track ends in the playlist.
GnomeMusic simply sends PlaybackStatus="Playing" for each new track. This confuses other applications that listen to the DBus/MPRIS2 messages. Other apps do not know that gnome-music changed track.

GnomeMusic should send:
 PlaybackStatus = "Palying" at start.
 ...
 ...
 Send PlaybackStatus = "Stopped"
 When track ends, or user stops playing, or user quits the application.

Please see:
https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Property:PlaybackStatus

Please fix this too.
https://bugs.launchpad.net/ubuntu/+source/gnome-music/+bug/1819037

Thank you for GnomeMusic.

Most kindly
  Moma & Bica (a small kind dog)
  Portugal

ProblemType: Bug
DistroRelease: Ubuntu 19.04
Package: gnome-music 3.31.90-1
ProcVersionSignature: Ubuntu 4.19.0-13.14-generic 4.19.20
Uname: Linux 4.19.0-13-generic x86_64
ApportVersion: 2.20.10-0ubuntu23
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Fri Mar 8 17:37:52 2019
InstallationDate: Installed on 2019-03-06 (1 days ago)
InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Alpha amd64 (20190203)
SourcePackage: gnome-music
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
moma (osmoma) wrote :
Revision history for this message
moma (osmoma) wrote :

JFYI:
I am testing GnomeMusic with audio-recorder.
https://launchpad.net/audio-recorder

Revision history for this message
Christopher (c-scharnagl) wrote :

Thank you for this report, too. I've reported the bug to the Gnome developers. You can track it at:
https://gitlab.gnome.org/GNOME/gnome-music/issues/282

Revision history for this message
Christopher (c-scharnagl) wrote :

The developer of gnome music couldn't reproduce the problem - dbus-monitor showed the playback values as excepted. Do you still have this problem?

Changed in gnome-music (Ubuntu):
status: New → Incomplete
Revision history for this message
moma (osmoma) wrote :

Hello,
Yes, you are right.

I can see that gnome-music sends a "Stopped" message when a track ends.
I used this "dbus-monitor" command to check it:

$ dbus-monitor "sender='org.gnome.Music'" | grep -A 5 "PlaybackStatus"
...
         string "PlaybackStatus"
         variant string "Stopped"

And if it was not the last one, a new track starts with.

         string "PlaybackStatus"
         variant string "Playing"
---------

I will now check what's my audio-recorder is really doing ;-)
It is a quite old program, but still used by thousands of users.

Thanks,
Happy 1.may !

Osmo Antero & Bica
Portugal

Revision history for this message
moma (osmoma) wrote :

Re-hello,
I just debugged the code of audio-recorder.

I can now see why it misses the "Stopped" signal from gnome-music.
The recorder always re-asks (re-requests) all data from the player, even it has received a "Stopped" or "Paused" signal.

Requesting all data from the player makes sens when the signal is "Playing".
Recorder wants to know track title, artist, URL, track length, etc.

This is what happens with gnome-music.
1) Recorder receives the {'PlaybackStatus': <'Stopped'>}. This is OK.

2) Recorder immediately (at the very same millisecond) requests all "Metadata" from the player (to fill its internal structures). Recorder expects that {'PlaybackStatus': <'Stopped'>},

3) Recorder receives all Metadata from gnome-music, but now PlaybackStatus is "Playing".
{'PlaybackStatus': <'Playing'>}

4) Recorder sends this Metadata ("Playing" data) to its message queue for processing.
Recording continues, recorder never saw the "Stopped" signal. It just saw "Playing".

Fixing this issue:
I can modify the code so audio-recorder never re-asks the data when PlaybackStatus is "Stopped" or "Paused". The recorder just need to know this value.

Of course, recorder must have all data (track title, artist, etc.) when PlaybackStatus is "Playing". Recorder always re-asks all "Metadata" to fill it fields.
------------

One thing.
Would you check if gnome-music sends a right PlaybackStatus value IMMEDIATELY after it had sent its PlaybackStatus = "Stopped" message. Maybe gnome-music is just very rapid to change its state.
As said: Recorder receives PlaybackStatus = "Playing" when it re-asks this value at the very same second.

Kindly
  Moma Antero
  Portugal

Revision history for this message
moma (osmoma) wrote :

I want to be more spesific:

https://bazaar.launchpad.net/~audio-recorder/audio-recorder/trunk/view/head:/src/dbus-mpris2.c

LINE 208:
static void mpris2_signal(GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
                               GVariant *parameters, gpointer user_data) {
...

Recorder received.
Raw data is:('org.mpris.MediaPlayer2.Player', {'PlaybackStatus': <'Stopped'>}, @as [])

Recorder re-asks all relevant data.
LINE 337: It calls
 mpris2_get_metadata(player);

--------------------

LINE 606:
void mpris2_get_metadata(gpointer player_rec) {

LINE 636: Re-asks the PlaybackStatus.

GVariant *result = mpris2_get_player_value(player, "PlaybackStatus");

Now the {'PlaybackStatus': <'Playing'>}

This is why the "Stopped" signals got lost.

Revision history for this message
moma (osmoma) wrote :

#!/usr/bin/bash

#A simple bash script to detect PlaybackStatus

PLAYER="org.gnome.Music"
FOUND=0

check_PlaybackStatus() {
    ret=$(gdbus call --session \
        --dest "$1" \
        --object-path '/org/mpris/MediaPlayer2' \
        --method 'org.freedesktop.DBus.Properties.Get' \
        'org.mpris.MediaPlayer2.Player' 'PlaybackStatus')

    echo "$ret"
}

dbus-monitor "type='signal',sender=$PLAYER,path='/org/mpris/MediaPlayer2',member='PropertiesChanged'" |
  while read line; do

    # Found "PlaybackStatus"?
    if [[ "$line" == *"PlaybackStatus"* ]]; then
        FOUND=$(($FOUND+1))
    fi

    # Next line should be "Playing" | "Paused" | "Stopped"
    if [[ "$line" == *"Playing"* && $FOUND == 1 ]]; then
        echo "$PLAYER says: I AM PLAYING."
        confirmed_state=$(check_PlaybackStatus "$PLAYER")
        echo "Confirmed state is: $confirmed_state"
        echo "-------------------------"
        FOUND=0
    fi

    if [[ "$line" == *"Paused"* && $FOUND == 1 ]]; then
        echo "$PLAYER says: I AM PAUSED."
        confirmed_state=$(check_PlaybackStatus "$PLAYER")
        echo "Confirmed state is: $confirmed_state"
        echo "-------------------------"
        FOUND=0
    fi

    if [[ "$line" == *"Stopped"* && $FOUND == 1 ]]; then
        echo "$PLAYER says: I AM STOPPED."
        confirmed_state=$(check_PlaybackStatus "$PLAYER")
        echo "Confirmed state is: $confirmed_state"
        echo "-------------------------"
        FOUND=0
    fi

  done

Revision history for this message
Christopher (c-scharnagl) wrote :

T

'One thing. Would you check if gnome-music sends a right PlaybackStatus value IMMEDIATELY after it had sent its PlaybackStatus = "Stopped" message.'

Sorry, I'm not a developer, just a user and don't know how to do this. (Maybe the people on the Gnome Music IRC channel irc://irc.gnome.org/gnome-music can help).

Christopher

Revision history for this message
Christopher (c-scharnagl) wrote :

And Thank you for the detailed explanation on the bug and dbus, I now leaned how to use dbus :-).

Kindly
  Christopher
  Munich, Germany

Changed in gnome-music (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
Christopher (c-scharnagl) wrote :

The developer now changed when the stop signal is send. Please see https://gitlab.gnome.org/GNOME/gnome-music/merge_requests/430 and https://gitlab.gnome.org/GNOME/gnome-music/issues/282 for more info.

Revision history for this message
moma (osmoma) wrote : Re: [Bug 1819198] Re: DBus/MPRIS2: GnomeMusic should send "Stopped" message when audio-track ends

Nice.

My audio-recorder is quite old software, and it needs a complete re-design
and re-coding.
Let us see what happens on that.
Nevertheless, thanks making GnomeMusic better and better. It counts a lot.

Christopher <email address hidden> escreveu no dia segunda,
10/06/2019 à(s) 11:41:

> The developer now changed when the stop signal is send. Please see
> https://gitlab.gnome.org/GNOME/gnome-music/merge_requests/430 and
> https://gitlab.gnome.org/GNOME/gnome-music/issues/282 for more info.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1819198
>
> Title:
> DBus/MPRIS2: GnomeMusic should send "Stopped" message when audio-track
> ends
>
> Status in gnome-music package in Ubuntu:
> Fix Released
>
> Bug description:
> Re-hi,
>
> GnomeMusic (via Dbus/MPRIS2) does not send "Stopped" message even
> audio-track ends in the playlist.
> GnomeMusic simply sends PlaybackStatus="Playing" for each new track.
> This confuses other applications that listen to the DBus/MPRIS2 messages.
> Other apps do not know that gnome-music changed track.
>
> GnomeMusic should send:
> PlaybackStatus = "Palying" at start.
> ...
> ...
> Send PlaybackStatus = "Stopped"
> When track ends, or user stops playing, or user quits the application.
>
> Please see:
>
> https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Property:PlaybackStatus
>
> Please fix this too.
> https://bugs.launchpad.net/ubuntu/+source/gnome-music/+bug/1819037
>
> Thank you for GnomeMusic.
>
> Most kindly
> Moma & Bica (a small kind dog)
> Portugal
>
> ProblemType: Bug
> DistroRelease: Ubuntu 19.04
> Package: gnome-music 3.31.90-1
> ProcVersionSignature: Ubuntu 4.19.0-13.14-generic 4.19.20
> Uname: Linux 4.19.0-13-generic x86_64
> ApportVersion: 2.20.10-0ubuntu23
> Architecture: amd64
> CurrentDesktop: ubuntu:GNOME
> Date: Fri Mar 8 17:37:52 2019
> InstallationDate: Installed on 2019-03-06 (1 days ago)
> InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Alpha amd64 (20190203)
> SourcePackage: gnome-music
> UpgradeStatus: No upgrade log present (probably fresh install)
>
> To manage notifications about this bug go to:
>
> https://bugs.launchpad.net/ubuntu/+source/gnome-music/+bug/1819198/+subscriptions
>

--
Sent from my PC, laptop or phone with Ubuntu-Linux.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.