Zren / plasma-applets

This monolithic repo has been broken up into individual repos for each widget.
84 stars 23 forks source link

Volume applet: current track progress is inaccurate #35

Closed AndydeCleyre closed 7 years ago

AndydeCleyre commented 8 years ago

Testing with Spotify.

  1. When I checked the applet soon after a song began, the applet's progress indicator already had the index well over half way to the end.
  2. When that song ended, the applet's progress indicator still had not reached the end, and continued to get closer as the next song played.
  3. The indicator reached the end well before that next song finished, and waited there until a third song began.
  4. When that third song began, the indicator only jumped back a little bit, nowhere near the beginning.
Zren commented 7 years ago

Hmmm, I ran into this recently. It seems that after awhile, there's only 1 source.

onNewData: console.log(JSON.stringify(mpris2Source.data, null, "\t"))
{
    "objectName": "",
    "@multiplex": {
        "CanControl": true,
        "CanGoNext": true,
        "CanGoPrevious": true,
        "CanQuit": true,
        "CanRaise": true,
        "CanSeek": true,
        "Desktop Icon Name": "clementine",
        "DesktopEntry": "clementine",
        "Fullscreen": false,
        "Identity": "Clementine",
        "InstancePid": 4507,
        "LoopStatus": "Playlist",
        "MaximumRate": 1,
        "Metadata": {
            "bitrate": 130,
            "mpris:artUrl": file:///tmp/clementine-art-bm4507.jpg,
            "mpris:length": 6860000000,
            "mpris:trackid": "/org/mpris/MediaPlayer2/Track/0",
            "xesam:contentCreated": "2017-03-02T11:06:10",
            "xesam:title": "'The Journey' (2 Hour Drum & Bass Mix)",
            "xesam:url": file:///home/chris/Music/Youtube/'The Journey' (2 Hour Drum & Bass Mix)-R8MWKsheHxk.mp3
        },
        "MinimumRate": 1,
        "PlaybackStatus": "Playing",
        "Position": 231765354,
        "Position last updated (UTC)": "2017-03-14T15:32:14.819Z",
        "Rate": 1,
        "Shuffle": false,
        "Source Name": "clementine",
        "SupportedMimeTypes": {
            "0": "application/ogg",
            "1": "application/x-ogg",
            "2": "application/x-ogm-audio",
            "3": "audio/aac",
            "4": "audio/mp4",
            "5": "audio/mpeg",
            "6": "audio/mpegurl",
            "7": "audio/ogg",
            "8": "audio/vnd.rn-realaudio",
            "9": "audio/vorbis",
            "10": "audio/x-flac",
            "11": "audio/x-mp3",
            "12": "audio/x-mpeg",
            "13": "audio/x-mpegurl",
            "14": "audio/x-ms-wma",
            "15": "audio/x-musepack",
            "16": "audio/x-oggflac",
            "17": "audio/x-pn-realaudio",
            "18": "audio/x-scpls",
            "19": "audio/x-speex",
            "20": "audio/x-vorbis",
            "21": "audio/x-vorbis+ogg",
            "22": "audio/x-wav",
            "23": "video/x-ms-asf",
            "24": "x-content/audio-player"
        },
        "SupportedUriSchemes": {
            "0": "file",
            "1": "http",
            "2": "cdda",
            "3": "smb",
            "4": "sftp"
        },
        "Volume": 1
    }
}

Which means

property bool hasPlayer: mpris2Source.sources.length >= 2 // We don't count @mutiplexSource
property int position: hasPlayer ? mpris2Source.data[mpris2Source.current].Position : 0
property bool canSeekMpris: hasPlayer && mpris2Source.data[mpris2Source.current].CanSeek
property bool canSeek: canSeekMpris && track && currentMetadata && currentMetadata["mpris:length"]

will be false, and 0, and unable to seek.

further logging gave me this:

qml: hasPlayer true
qml: currentMetadata [object Object]
qml: position 1108771687
qml: length -2147483648
qml: canSeek true canSeekMpris true

Which means there's an overflow on "mpris:length": 6860000000, somehow... 2^(32-1) = 2147483648 which would make it the signed minimum I think.

looks at datatype... well duh.

http://doc.qt.io/qt-5/qml-int.html

The possible int values range from around -2000000000 to around 2000000000, although most types will only accept a reduced range (which they mention in their documentation).

Changing both types to double seems to work for that one 2h long song.

It's interesting to note that postion and length are both ints in the default widget.

https://github.com/KDE/plasma-workspace/blob/master/applets/mediacontroller/contents/ui/ExpandedRepresentation.qml#L38-L40