Ubuntu Pastebin

Paste from Pat McGowan at Thu, 4 Aug 2016 19:25:44 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
        // FIXME: Workaround for pad.lv/1494031 by querying gst as it does not
        // emit until it changes to the PLAYING state. But by asking for a
        // value we get gst to perform a query and return a result
        // However this has to be done once the source is set, hence the delay
        //
        // NOTE: This does not solve when the currentIndex is removed though
        Timer {
            id: refreshProgressTimer
            interval: 48
            repeat: false
            onTriggered: {
                if (!progressSliderMusic.seeking) {
                    musicToolbarFullPositionLabel.text = durationToString(player.mediaPlayer.position);
                    musicToolbarFullDurationLabel.text = durationToString(player.mediaPlayer.duration || 1);

                    progressSliderMusic.value = player.mediaPlayer.position
                    // fallback to 1 when 0 so that the progress bar works
                    progressSliderMusic.maximumValue = player.mediaPlayer.duration || 1
                }
            }
        }

        Connections {
            target: player.mediaPlayer.playlist
            // Call timer when source or index changes
            // so we call even if there are duplicate sources or source removal
            onCurrentItemSourceChanged: refreshProgressTimer.start()
            onCurrentIndexChanged: refreshProgressTimer.start()
        }
Download as text