browsing works!
This commit is contained in:
parent
564c098acd
commit
154772d6ea
32
webclient/js/controls.js
vendored
32
webclient/js/controls.js
vendored
@ -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;
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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 += '<li><a href="#" onclick="return getBrowseDir(this.id);" id="' + rooturi + '">..</a></li>';
|
||||
}
|
||||
|
||||
console.log('new:' + rooturi);
|
||||
// console.log('new:' + rooturi);
|
||||
|
||||
|
||||
console.log('a1');
|
||||
for (var i = 0; i < resultArr.length; i++) {
|
||||
if(resultArr[i].type == 'track' ) {
|
||||
child += '<li><a href="#" onclick="return playBrowsedTracks(0, this.id);" id="' + resultArr[i].uri + '"">' + resultArr[i].name + '</a></li>';
|
||||
child += '<li><a href="#" class="browsetrack" onclick="return playBrowsedTracks(0, this.id);" id="' + resultArr[i].uri + '"">' + resultArr[i].name + '</a></li>';
|
||||
} else {
|
||||
child += '<li><a href="#" onclick="return getBrowseDir(this.id);" id="' + resultArr[i].uri + '"">' + resultArr[i].name + '</a></li>';
|
||||
}
|
||||
};
|
||||
console.log(child);
|
||||
// console.log(child);
|
||||
|
||||
$('#browselist').html(child);
|
||||
// scrollToTracklist();
|
||||
|
||||
showLoading(false);
|
||||
}
|
||||
|
||||
@ -177,6 +176,7 @@ function processGetTracklist(resultArr) {
|
||||
*********************************************************/
|
||||
function processCurrentPlaylist(resultArr) {
|
||||
currentplaylist = resultArr;
|
||||
// console.log(resultArr);
|
||||
resultsToTables(resultArr, CURRENT_PLAYLIST_TABLE);
|
||||
mopidy.playback.getCurrentTrack().then(processCurrenttrack, console.error);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user