on xenial help sign in
Always use a playlist for playing even if it's just for one song
10632b7Albert Astals Cid
plugins/Dash/DashAudioPlayer.qml+8−13
@@ -39,13 +39,8 @@ QtObject {
39
39
40 function playSource(newSource, newPlaylist) {
40 function playSource(newSource, newPlaylist) {
41 stop();
41 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();
45 if (newPlaylist) {
43 if (newPlaylist) {
46− playlist.clear();
47− audio.playlist = playlist;
48−
49 // Look for newSource in newPlaylist
44 // Look for newSource in newPlaylist
50 var sourceIndex = -1;
45 var sourceIndex = -1;
51 for (var i in newPlaylist) {
46 for (var i in newPlaylist) {
@@ -63,10 +58,11 @@ QtObject {
63 for (var i in newPlaylist) {
58 for (var i in newPlaylist) {
64 urls.push(newPlaylist[i]);
59 urls.push(newPlaylist[i]);
65 }
60 }
66− playlist.addSources(urls);
61+ audio.playlist.addSources(urls);
67− playlist.currentIndex = sourceIndex;
62+ audio.playlist.currentIndex = sourceIndex;
68 } else {
63 } else {
69− audio.source = newSource;
64+ audio.playlist.addSource(newSource);
65+ audio.playlist.currentIndex = 0;
70 }
66 }
71 play();
67 play();
72 }
68 }
@@ -86,13 +82,12 @@ QtObject {
86 property QtObject audio: Audio {
82 property QtObject audio: Audio {
87 id: audio
83 id: audio
88 objectName: "audio"
84 objectName: "audio"
85+ playlist: Playlist {
86+ objectName: "playlist"
87+ }
89
88
90 onErrorStringChanged: console.warn("Dash Audio player error:", errorString)
89 onErrorStringChanged: console.warn("Dash Audio player error:", errorString)
91 }
90 }
92− property QtObject playlist: Playlist {
93− id: playlist
94− objectName: "playlist"
95− }
96
91
97 function lengthToString(s) {
92 function lengthToString(s) {
98 if (typeof(s) !== "number" || s < 0) return "";
93 if (typeof(s) !== "number" || s < 0) return "";