on xenial help sign in
improve determination of playing item
7356cfaMichael Zanetti
Dash/Music/MusicPreview.qml+5−8
@@ -59,6 +59,8 @@ GenericPreview {
59 objectName: "audioPlayer"
59 objectName: "audioPlayer"
60 property real percent: audioPlayer.position * 100 / audioPlayer.duration
60 property real percent: audioPlayer.position * 100 / audioPlayer.duration
61
61
62+ property Item playingItem
63+
62 Component.onDestruction: {
64 Component.onDestruction: {
63 audioPlayer.stop();
65 audioPlayer.stop();
64 }
66 }
@@ -78,11 +80,11 @@ GenericPreview {
78
80
79 Column {
81 Column {
80 anchors { left: parent.left; right: parent.right }
82 anchors { left: parent.left; right: parent.right }
83+ visible: trackRepeater.count > 0
81
84
82 ThinDivider {
85 ThinDivider {
83 objectName: "topDivider"
86 objectName: "topDivider"
84 anchors { left: parent.left; right: parent.right }
87 anchors { left: parent.left; right: parent.right }
85− visible: trackRepeater.count > 0
86 }
88 }
87
89
88 Repeater {
90 Repeater {
@@ -96,19 +98,14 @@ GenericPreview {
96 objectName: "trackItem" + index
98 objectName: "trackItem" + index
97 width: parent.width
99 width: parent.width
98 height: units.gu(5)
100 height: units.gu(5)
99− property bool isPlayingItem: false
101+ property bool isPlayingItem: audioPlayer.playingItem == trackItem
100−
101− Connections {
102− target: audioPlayer
103− onSourceChanged: trackItem.isPlayingItem = false;
104− }
105
102
106 function play() {
103 function play() {
107 audioPlayer.stop();
104 audioPlayer.stop();
108 // Make sure we change the source, even if two items point to the same uri location
105 // Make sure we change the source, even if two items point to the same uri location
109 audioPlayer.source = "";
106 audioPlayer.source = "";
110 audioPlayer.source = model.uri;
107 audioPlayer.source = model.uri;
111− isPlayingItem = true;
108+ audioPlayer.playingItem = trackItem;
112 audioPlayer.play();
109 audioPlayer.play();
113 }
110 }
114
111