on xenial help sign in
Always use a playlist for playing even if it's just for one song
commit10632b7483f532f8996eac505c20016d63a80a9a authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 30 Oct 2015, 13:22 (11 years ago) parentc183767
1 file changed+8−13
plugins/Dash/DashAudioPlayer.qml+8−13
plugins/Dash/DashAudioPlayer.qml+8−13
@@ -39,13 +39,8 @@ QtObject {
3939
4040 function playSource(newSource, newPlaylist) {
4141 stop();
42− // Make sure we change the source, even if two items point to the same uri location
43− audio.source = "";
44− audio.playlist = null;
42+ audio.playlist.clear();
4543 if (newPlaylist) {
46− playlist.clear();
47− audio.playlist = playlist;
48−
4944 // Look for newSource in newPlaylist
5045 var sourceIndex = -1;
5146 for (var i in newPlaylist) {
@@ -63,10 +58,11 @@ QtObject {
6358 for (var i in newPlaylist) {
6459 urls.push(newPlaylist[i]);
6560 }
66− playlist.addSources(urls);
67− playlist.currentIndex = sourceIndex;
61+ audio.playlist.addSources(urls);
62+ audio.playlist.currentIndex = sourceIndex;
6863 } else {
69− audio.source = newSource;
64+ audio.playlist.addSource(newSource);
65+ audio.playlist.currentIndex = 0;
7066 }
7167 play();
7268 }
@@ -86,13 +82,12 @@ QtObject {
8682 property QtObject audio: Audio {
8783 id: audio
8884 objectName: "audio"
85+ playlist: Playlist {
86+ objectName: "playlist"
87+ }
8988
9089 onErrorStringChanged: console.warn("Dash Audio player error:", errorString)
9190 }
92− property QtObject playlist: Playlist {
93− id: playlist
94− objectName: "playlist"
95− }
9691
9792 function lengthToString(s) {
9893 if (typeof(s) !== "number" || s < 0) return "";