diff --git a/webclient/js/controls.js b/webclient/js/controls.js index 6380833..4098917 100755 --- a/webclient/js/controls.js +++ b/webclient/js/controls.js @@ -8,31 +8,29 @@ function playBrowsedTracks(addtoqueue, trackid) { mopidy.tracklist.clear(); } toast('Loading...'); + var selected = 0, counter = 0; -// first add track to be played, then the other tracks - mopidy.tracklist.add(trackid); -// mopidy.tracklist.add({ 'uri':trackid }); - - console.log(trackid); - return false; +//only add one station for dirble, otherwise add all tracks + if ( trackid.indexOf('dirble') != -1 ) { + mopidy.tracklist.add(null, null, trackid); + } else { + //add all items in the playlist + $('.browsetrack').each(function() { + mopidy.tracklist.add(null, null, this.id); + if (this.id = trackid) { + selected = counter; + } + counter++; + } ); + } - //wait 1.5 second before adding the rest to give server the time to start playing - setTimeout(function() { - mopidy.tracklist.add(tracks.slice(0, selected), 0); - if (selected < tracks.length) { - mopidy.tracklist.add(tracks.slice(selected + 1) ); - } - }, 1500); - - -// mopidy.playback.changeTrack(tracks[selected]); + selected = counter - selected; for (var i = 0; i <= selected; i++) { mopidy.playback.next(); } mopidy.playback.play(); //tracks[selected]); - //console.log(selected); return false; } diff --git a/webclient/js/gui.js b/webclient/js/gui.js index b403603..ba451e0 100755 --- a/webclient/js/gui.js +++ b/webclient/js/gui.js @@ -484,7 +484,7 @@ $(document).ready(function(event) { // Connect to server mopidy = new Mopidy(); - mopidy.on(console.log.bind(console)); // Log all events +// mopidy.on(console.log.bind(console)); // Log all events //initialize events initSocketevents(); diff --git a/webclient/js/library.js b/webclient/js/library.js index f955f58..e1d05eb 100755 --- a/webclient/js/library.js +++ b/webclient/js/library.js @@ -157,7 +157,7 @@ function getPlaylists() { function getBrowseDir(rootdir) { // get directory to browse - console.log('browse init: ' + rootdir); +// console.log('browse init: ' + rootdir); showLoading(true); mopidy.library.browse(rootdir).then(processBrowseDir, console.error); } diff --git a/webclient/js/process_ws.js b/webclient/js/process_ws.js index 26d0be8..cdaa822 100755 --- a/webclient/js/process_ws.js +++ b/webclient/js/process_ws.js @@ -66,7 +66,7 @@ function processBrowseDir(resultArr) { if ((!resultArr) || (resultArr == '')) { return; } - console.log(resultArr); +// console.log(resultArr); if (resultArr.length == 0) { return; @@ -88,7 +88,7 @@ function processBrowseDir(resultArr) { rooturi = rooturi.replace(":track:", ":directory:"); } - console.log(uri, lastindex, rooturi); +// console.log(uri, lastindex, rooturi); colonindex = rooturi.lastIndexOf(':'); slashindex = rooturi.lastIndexOf('/'); @@ -96,7 +96,7 @@ function processBrowseDir(resultArr) { lastindex = (colonindex > slashindex) ? colonindex : slashindex; rooturi = rooturi.slice(0, lastindex); - console.log(rooturi); +// console.log(rooturi); if (rooturi.indexOf(':') == -1 ) { rooturi = ''; @@ -105,20 +105,19 @@ function processBrowseDir(resultArr) { child += '