@@ -34,7 +34,7 @@ import Ubuntu.Components 0.1
35PreviewWidget {
35PreviewWidget {
37− implicitHeight: childrenRect.height
37+ height: childrenRect.height
39 onIsCurrentPreviewChanged: if (!isCurrentPreview) audio.stop()
39 onIsCurrentPreviewChanged: if (!isCurrentPreview) audio.stop()
@@ -46,24 +46,24 @@ PreviewWidget {
46 property Item playingItem
46 property Item playingItem
48 Component.onDestruction: {
48 Component.onDestruction: {
49− // destructing the component doesn't automatically send stop to the media service, probably a bug in QtMultimedia
49+ // destroying the component doesn't automatically send stop to the media service, probably a bug in QtMultimedia
50 audio.stop();
50 audio.stop();
53 onErrorStringChanged: console.warn("Audio player error:", errorString)
53 onErrorStringChanged: console.warn("Audio player error:", errorString)
55 function lengthToString(s) {
55 function lengthToString(s) {
56− if (s <= 0 || s === undefined) return ""
56+ if (s <= 0 || typeof(s) !== "number") return "";
58− var sec = "" + s % 60
58+ var sec = "" + s % 60;
59− if (sec.length == 1) sec = "0" + sec
59+ if (sec.length == 1) sec = "0" + sec;
60− var hour = Math.floor(s / 3600)
60+ var hour = Math.floor(s / 3600);
61 if (hour < 1) {
61 if (hour < 1) {
62− return Math.floor(s / 60) + ":" + sec
62+ return Math.floor(s / 60) + ":" + sec;
64− var min = "" + Math.floor(s / 60) % 60
64+ var min = "" + Math.floor(s / 60) % 60;
65− if (min.length == 1) min = "0" + min
65+ if (min.length == 1) min = "0" + min;
66− return hour + ":" + min + ":" + sec
66+ return hour + ":" + min + ":" + sec;
@@ -77,6 +77,15 @@ PreviewWidget {
77 objectName: "trackRepeater"
77 objectName: "trackRepeater"
78 model: root.widgetData["tracks"]
78 model: root.widgetData["tracks"]
80+ function play(item, source) {
82+ // Make sure we change the source, even if two items point to the same uri location
84+ audio.source = source;
85+ audio.playingItem = item;
80 delegate: Item {
89 delegate: Item {
81 id: trackItem
90 id: trackItem
82 objectName: "trackItem" + index
91 objectName: "trackItem" + index
@@ -86,15 +95,6 @@ PreviewWidget {
86 anchors { left: parent.left; right: parent.right }
95 anchors { left: parent.left; right: parent.right }
87 height: units.gu(5)
96 height: units.gu(5)
91− // Make sure we change the source, even if two items point to the same uri location
93− audio.source = modelData["source"];
94− audio.playingItem = trackItem;
99 id: trackRow
99 id: trackRow
@@ -120,11 +120,11 @@ PreviewWidget {
120 if (trackItem.isPlayingItem) {
120 if (trackItem.isPlayingItem) {
121 if (audio.playbackState == Audio.PlayingState) {
121 if (audio.playbackState == Audio.PlayingState) {
122 audio.pause();
122 audio.pause();
123− } else if (audio.playbackState == Audio.PausedState){
123+ } else if (audio.playbackState == Audio.PausedState) {
124 audio.play();
124 audio.play();
127− trackItem.play();
127+ trackRepeater.play(trackItem, modelData["source"]);
@@ -155,7 +155,7 @@ PreviewWidget {
155 color: Theme.palette.selected.backgroundText
155 color: Theme.palette.selected.backgroundText
156 fontSize: "small"
156 fontSize: "small"
157 horizontalAlignment: Text.AlignLeft
157 horizontalAlignment: Text.AlignLeft
158− text: modelData["subtitle"] !== undefined ? modelData["subtitle"] : ""
158+ text: (modelData["subtitle"] && modelData["subtitle"] !== undefined) ? modelData["subtitle"] : ""
159 elide: Text.ElideRight
159 elide: Text.ElideRight