Merge pull request #150 from jcass77/fix/79_explicit_calling_convention
Implement the new 'by-position-or-by-name' Mopidy.js calling convention
This commit is contained in:
commit
4992d038a9
@ -105,6 +105,7 @@ v2.1.0 (UNRELEASED)
|
|||||||
(Fixes: `#144 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/144>`_).
|
(Fixes: `#144 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/144>`_).
|
||||||
- Re-align the menu and search buttons in the title bar.
|
- Re-align the menu and search buttons in the title bar.
|
||||||
(Fixes: `#148 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/148>`_).
|
(Fixes: `#148 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/148>`_).
|
||||||
|
- Use explicit Mopidy.js calling convention. (Fixes: `#79 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/79>`_).
|
||||||
|
|
||||||
|
|
||||||
v2.0.0 (2015-03-26)
|
v2.0.0 (2015-03-26)
|
||||||
|
|||||||
54
mopidy_musicbox_webclient/static/js/controls.js
vendored
54
mopidy_musicbox_webclient/static/js/controls.js
vendored
@ -32,7 +32,7 @@ function playBrowsedTracks(action, trackIndex) {
|
|||||||
var maybePlay = function(tlTracks) {
|
var maybePlay = function(tlTracks) {
|
||||||
if (action === PLAY_NOW || action === PLAY_ALL) {
|
if (action === PLAY_NOW || action === PLAY_ALL) {
|
||||||
var playIndex = (action === PLAY_ALL) ? trackIndex : 0;
|
var playIndex = (action === PLAY_ALL) ? trackIndex : 0;
|
||||||
mopidy.playback.play(tlTracks[playIndex]);
|
mopidy.playback.play({'tl_track': tlTracks[playIndex]});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,13 +40,13 @@ function playBrowsedTracks(action, trackIndex) {
|
|||||||
case PLAY_NOW:
|
case PLAY_NOW:
|
||||||
case PLAY_NEXT:
|
case PLAY_NEXT:
|
||||||
mopidy.tracklist.index().then(function (currentIndex) {
|
mopidy.tracklist.index().then(function (currentIndex) {
|
||||||
mopidy.tracklist.add(null, currentIndex + 1, null, trackUris).then(maybePlay);
|
mopidy.tracklist.add({'at_position': currentIndex + 1, 'uris': trackUris}).then(maybePlay);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case ADD_THIS_BOTTOM:
|
case ADD_THIS_BOTTOM:
|
||||||
case ADD_ALL_BOTTOM:
|
case ADD_ALL_BOTTOM:
|
||||||
case PLAY_ALL:
|
case PLAY_ALL:
|
||||||
mopidy.tracklist.add(null, null, null, trackUris).then(maybePlay);
|
mopidy.tracklist.add({'uris': trackUris}).then(maybePlay);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -91,21 +91,21 @@ function playTrack(action) {
|
|||||||
case PLAY_NOW:
|
case PLAY_NOW:
|
||||||
case PLAY_NOW_SEARCH:
|
case PLAY_NOW_SEARCH:
|
||||||
mopidy.tracklist.clear().then(
|
mopidy.tracklist.clear().then(
|
||||||
mopidy.tracklist.add(null, null, null, trackUris).then(
|
mopidy.tracklist.add({'uris': trackUris}).then(
|
||||||
function(tlTracks) {
|
function(tlTracks) {
|
||||||
mopidy.playback.play(tlTracks[selected])
|
mopidy.playback.play({'tl_track': tlTracks[selected]})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case PLAY_NEXT:
|
case PLAY_NEXT:
|
||||||
mopidy.tracklist.index().then(function(currentIndex) {
|
mopidy.tracklist.index().then(function(currentIndex) {
|
||||||
mopidy.tracklist.add(null, currentIndex + 1, null, trackUris);
|
mopidy.tracklist.add({'at_position': currentIndex + 1, 'uris': trackUris});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case ADD_THIS_BOTTOM:
|
case ADD_THIS_BOTTOM:
|
||||||
case ADD_ALL_BOTTOM:
|
case ADD_ALL_BOTTOM:
|
||||||
mopidy.tracklist.add(null, null, null, trackUris);
|
mopidy.tracklist.add({'uris': trackUris});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -122,7 +122,7 @@ function playTrackByUri(track_uri, playlist_uri) {
|
|||||||
// Find track that was selected
|
// Find track that was selected
|
||||||
for (var selected = 0; selected < tltracks.length; selected++) {
|
for (var selected = 0; selected < tltracks.length; selected++) {
|
||||||
if (tltracks[selected].track.uri == track_uri) {
|
if (tltracks[selected].track.uri == track_uri) {
|
||||||
mopidy.playback.play(tltracks[selected]);
|
mopidy.playback.play({'tl_track': tltracks[selected]});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,11 +141,11 @@ function playTrackByUri(track_uri, playlist_uri) {
|
|||||||
|
|
||||||
toast('Loading...');
|
toast('Loading...');
|
||||||
|
|
||||||
mopidy.tracklist.add(null, null, playlist_uri).then(function(tltracks) {
|
mopidy.tracklist.add({'uris': [playlist_uri]}).then(function(tltracks) {
|
||||||
// Can fail for all sorts of reasons. If so, just add individually.
|
// Can fail for all sorts of reasons. If so, just add individually.
|
||||||
if (tltracks.length == 0) {
|
if (tltracks.length == 0) {
|
||||||
var trackUris = getTracksFromUri(playlist_uri, false);
|
var trackUris = getTracksFromUri(playlist_uri, false);
|
||||||
mopidy.tracklist.add(null, null, null, trackUris).then(findAndPlayTrack);
|
mopidy.tracklist.add({'uris': trackUris}).then(findAndPlayTrack);
|
||||||
} else {
|
} else {
|
||||||
findAndPlayTrack(tltracks);
|
findAndPlayTrack(tltracks);
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ function playTrackQueueByTlid(uri, tlid) {
|
|||||||
}).then(
|
}).then(
|
||||||
function(tltracks) {
|
function(tltracks) {
|
||||||
if (tltracks.length > 0) {
|
if (tltracks.length > 0) {
|
||||||
mopidy.playback.play(tltracks[0]);
|
mopidy.playback.play({'tl_track': tltracks[0]});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Failed to play selected track ', tlid);
|
console.log('Failed to play selected track ', tlid);
|
||||||
@ -203,7 +203,7 @@ function removeTrack() {
|
|||||||
|
|
||||||
tlid = parseInt($('#popupQueue').data("tlid"));
|
tlid = parseInt($('#popupQueue').data("tlid"));
|
||||||
console.log(tlid);
|
console.log(tlid);
|
||||||
mopidy.tracklist.remove({'tlid':[tlid]});
|
mopidy.tracklist.remove({'tlid': [tlid]});
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearQueue() {
|
function clearQueue() {
|
||||||
@ -225,9 +225,9 @@ function saveQueue() {
|
|||||||
exists = exists || existing[i].uri.indexOf("m3u:") == 0 || existing[i].uri.indexOf("local:") == 0;
|
exists = exists || existing[i].uri.indexOf("m3u:") == 0 || existing[i].uri.indexOf("local:") == 0;
|
||||||
}
|
}
|
||||||
if (!exists || window.confirm("Overwrite existing playlist \"" + plname + "\"?")) {
|
if (!exists || window.confirm("Overwrite existing playlist \"" + plname + "\"?")) {
|
||||||
mopidy.playlists.create(plname, "local").then(function(playlist) {
|
mopidy.playlists.create({'name': plname, 'uri_scheme': "local"}).then(function(playlist) {
|
||||||
playlist.tracks = tracks;
|
playlist.tracks = tracks;
|
||||||
mopidy.playlists.save(playlist).then();
|
mopidy.playlists.save({'playlist': playlist}).then();
|
||||||
getPlaylists();
|
getPlaylists();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -336,19 +336,19 @@ function setSingle(nwsingle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function doRandom() {
|
function doRandom() {
|
||||||
mopidy.tracklist.setRandom(!random).then();
|
mopidy.tracklist.setRandom({'value': !random}).then();
|
||||||
}
|
}
|
||||||
|
|
||||||
function doRepeat() {
|
function doRepeat() {
|
||||||
mopidy.tracklist.setRepeat(!repeat).then();
|
mopidy.tracklist.setRepeat({'value': !repeat}).then();
|
||||||
}
|
}
|
||||||
|
|
||||||
function doConsume() {
|
function doConsume() {
|
||||||
mopidy.tracklist.setConsume(!consume).then();
|
mopidy.tracklist.setConsume({'value': !consume}).then();
|
||||||
}
|
}
|
||||||
|
|
||||||
function doSingle() {
|
function doSingle() {
|
||||||
mopidy.tracklist.setSingle(!single).then();
|
mopidy.tracklist.setSingle({'value': !single}).then();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ function doSeekPos(value) {
|
|||||||
function triggerPos() {
|
function triggerPos() {
|
||||||
if (mopidy) {
|
if (mopidy) {
|
||||||
posChanging = true;
|
posChanging = true;
|
||||||
mopidy.playback.seek(newposition);
|
mopidy.playback.seek({'time_position': newposition});
|
||||||
resumePosTimer();
|
resumePosTimer();
|
||||||
posChanging = false;
|
posChanging = false;
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ function doVolume(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function triggerVolume() {
|
function triggerVolume() {
|
||||||
mopidy.playback.setVolume(parseInt(volumeChanging));
|
mopidy.playback.setVolume({'volume': parseInt(volumeChanging)});
|
||||||
volumeChanging = 0;
|
volumeChanging = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ function setMute(nwmute) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function doMute() {
|
function doMute() {
|
||||||
mopidy.mixer.setMute(!mute);
|
mopidy.mixer.setMute({'mute': !mute});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************
|
/**************************
|
||||||
@ -483,7 +483,7 @@ function playStreamUri(uri) {
|
|||||||
document.activeElement.blur();
|
document.activeElement.blur();
|
||||||
clearQueue();
|
clearQueue();
|
||||||
$("input").blur();
|
$("input").blur();
|
||||||
mopidy.tracklist.add(null, null, nwuri);
|
mopidy.tracklist.add({'uris': [nwuri]});
|
||||||
mopidy.playback.play();
|
mopidy.playback.play();
|
||||||
} else {
|
} else {
|
||||||
toast('No valid url!');
|
toast('No valid url!');
|
||||||
@ -514,7 +514,7 @@ function getPlaylistByName(name, scheme, create) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (create) {
|
if (create) {
|
||||||
return mopidy.playlists.create(name, scheme).done(function(plist) {
|
return mopidy.playlists.create({'name': name, 'uri_scheme': scheme}).done(function(plist) {
|
||||||
console.log("Created playlist '%s'", plist.name);
|
console.log("Created playlist '%s'", plist.name);
|
||||||
return plist;
|
return plist;
|
||||||
});
|
});
|
||||||
@ -524,7 +524,7 @@ function getPlaylistByName(name, scheme, create) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPlaylistFull(uri) {
|
function getPlaylistFull(uri) {
|
||||||
return mopidy.playlists.lookup(uri).then(function(pl) {
|
return mopidy.playlists.lookup({'uri': uri}).then(function(pl) {
|
||||||
playlists[uri] = pl;
|
playlists[uri] = pl;
|
||||||
return pl;
|
return pl;
|
||||||
});
|
});
|
||||||
@ -541,7 +541,7 @@ function getFavourites() {
|
|||||||
function addFavourite(uri, name) {
|
function addFavourite(uri, name) {
|
||||||
var uri = uri || $('#streamuriinput').val().trim();
|
var uri = uri || $('#streamuriinput').val().trim();
|
||||||
var name = name || $('#streamnameinput').val().trim();
|
var name = name || $('#streamnameinput').val().trim();
|
||||||
mopidy.library.lookup(null, [uri]).then(function(results) {
|
mopidy.library.lookup({'uris': [uri]}).then(function(results) {
|
||||||
var newTracks = results[uri];
|
var newTracks = results[uri];
|
||||||
if (newTracks.length == 1) {
|
if (newTracks.length == 1) {
|
||||||
// TODO: Supporting adding an entire playlist?
|
// TODO: Supporting adding an entire playlist?
|
||||||
@ -556,7 +556,7 @@ function addFavourite(uri, name) {
|
|||||||
} else {
|
} else {
|
||||||
favourites.tracks = [newTracks[0]];
|
favourites.tracks = [newTracks[0]];
|
||||||
}
|
}
|
||||||
mopidy.playlists.save(favourites).then(function(s) {
|
mopidy.playlists.save({'playlist': favourites}).then(function(s) {
|
||||||
showFavourites();
|
showFavourites();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -577,7 +577,7 @@ function deleteFavourite(index) {
|
|||||||
var name = favourites.tracks[index].name;
|
var name = favourites.tracks[index].name;
|
||||||
if (confirm("Are you sure you want to remove '" + name + "'?")) {
|
if (confirm("Are you sure you want to remove '" + name + "'?")) {
|
||||||
favourites.tracks.splice(index, 1);
|
favourites.tracks.splice(index, 1);
|
||||||
mopidy.playlists.save(favourites).then(function(s) {
|
mopidy.playlists.save({'playlist': favourites}).then(function(s) {
|
||||||
showFavourites();
|
showFavourites();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -410,8 +410,8 @@ function getPlaylistTracks(uri) {
|
|||||||
return Mopidy.when(playlists[uri].tracks);
|
return Mopidy.when(playlists[uri].tracks);
|
||||||
} else {
|
} else {
|
||||||
showLoading(true);
|
showLoading(true);
|
||||||
return mopidy.playlists.getItems(uri).then(function(refs) {
|
return mopidy.playlists.getItems({'uri': uri}).then(function(refs) {
|
||||||
return processPlaylistItems({'uri':uri, 'items':refs});
|
return processPlaylistItems({'uri': uri, 'items': refs});
|
||||||
}, console.error);
|
}, console.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -479,10 +479,11 @@ $(document).ready(function(event) {
|
|||||||
// Connect to server
|
// Connect to server
|
||||||
if (websocketUrl) {
|
if (websocketUrl) {
|
||||||
mopidy = new Mopidy({
|
mopidy = new Mopidy({
|
||||||
webSocketUrl: websocketUrl // wslocation is set in index.html from the extention config.
|
webSocketUrl: websocketUrl, // wslocation is set in index.html from the extention config.
|
||||||
|
callingConvention: 'by-position-or-by-name'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mopidy = new Mopidy();
|
mopidy = new Mopidy({callingConvention: 'by-position-or-by-name'});
|
||||||
}
|
}
|
||||||
|
|
||||||
//initialize events
|
//initialize events
|
||||||
|
|||||||
@ -30,7 +30,7 @@ function initSearch() {
|
|||||||
$("#searchresults").hide();
|
$("#searchresults").hide();
|
||||||
|
|
||||||
if (searchService != 'all') {
|
if (searchService != 'all') {
|
||||||
mopidy.library.search({any:[value]}, [searchService + ':']).then(processSearchResults, console.error);
|
mopidy.library.search({'query': {any:[value]}, 'uris': [searchService + ':']}).then(processSearchResults, console.error);
|
||||||
} else {
|
} else {
|
||||||
mopidy.getUriSchemes().then(function (schemes) {
|
mopidy.getUriSchemes().then(function (schemes) {
|
||||||
var query = {},
|
var query = {},
|
||||||
@ -48,7 +48,7 @@ function initSearch() {
|
|||||||
} else {
|
} else {
|
||||||
query = {any: [value]};
|
query = {any: [value]};
|
||||||
}
|
}
|
||||||
mopidy.library.search(query, uris).then(processSearchResults, console.error);
|
mopidy.library.search({'query': query, 'uris': uris}).then(processSearchResults, console.error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +211,10 @@ function getBrowseDir(rootdir) {
|
|||||||
} else {
|
} else {
|
||||||
browseStack.push(rootdir);
|
browseStack.push(rootdir);
|
||||||
}
|
}
|
||||||
mopidy.library.browse(rootdir).then(processBrowseDir, console.error);
|
if (!rootdir) {
|
||||||
|
rootdir = null;
|
||||||
|
}
|
||||||
|
mopidy.library.browse({'uri': rootdir}).then(processBrowseDir, console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentPlaylist() {
|
function getCurrentPlaylist() {
|
||||||
@ -263,7 +266,8 @@ function showArtist(nwuri) {
|
|||||||
//TODO cache
|
//TODO cache
|
||||||
$('#h_artistname').html('');
|
$('#h_artistname').html('');
|
||||||
showLoading(true);
|
showLoading(true);
|
||||||
mopidy.library.lookup(nwuri).then(function(resultArr) {
|
mopidy.library.lookup({'uris': [nwuri]}).then(function(resultDict) {
|
||||||
|
var resultArr = resultDict[Object.keys(resultDict)[0]];
|
||||||
resultArr.uri = nwuri;
|
resultArr.uri = nwuri;
|
||||||
processArtistResults(resultArr);
|
processArtistResults(resultArr);
|
||||||
}, console.error);
|
}, console.error);
|
||||||
@ -288,7 +292,8 @@ function showAlbum(uri) {
|
|||||||
$('#coverpopupalbumname').html(albumname);
|
$('#coverpopupalbumname').html(albumname);
|
||||||
$('#coverpopupartist').html(artistname);
|
$('#coverpopupartist').html(artistname);
|
||||||
showLoading(false);
|
showLoading(false);
|
||||||
mopidy.library.lookup(uri).then(function(resultArr) {
|
mopidy.library.lookup({'uris': [uri]}).then(function(resultDict) {
|
||||||
|
var resultArr = resultDict[Object.keys(resultDict)[0]];
|
||||||
resultArr.uri = uri;
|
resultArr.uri = uri;
|
||||||
processAlbumResults(resultArr);
|
processAlbumResults(resultArr);
|
||||||
}, console.error);
|
}, console.error);
|
||||||
@ -296,7 +301,8 @@ function showAlbum(uri) {
|
|||||||
showLoading(true);
|
showLoading(true);
|
||||||
$('#h_albumname').html('');
|
$('#h_albumname').html('');
|
||||||
$('#h_albumartist').html('');
|
$('#h_albumartist').html('');
|
||||||
mopidy.library.lookup(uri).then(function(resultArr) {
|
mopidy.library.lookup({'uris': [uri]}).then(function(resultDict) {
|
||||||
|
var resultArr = resultDict[Object.keys(resultDict)[0]];
|
||||||
resultArr.uri = uri;
|
resultArr.uri = uri;
|
||||||
processAlbumResults(resultArr);
|
processAlbumResults(resultArr);
|
||||||
}, console.error);
|
}, console.error);
|
||||||
|
|||||||
@ -118,9 +118,10 @@ function processBrowseDir(resultArr) {
|
|||||||
iconClass = getMediaClass(resultArr[i].uri);
|
iconClass = getMediaClass(resultArr[i].uri);
|
||||||
if (resultArr[i].type == 'track') {
|
if (resultArr[i].type == 'track') {
|
||||||
//console.log(resultArr[i]);
|
//console.log(resultArr[i]);
|
||||||
mopidy.library.lookup(resultArr[i].uri).then(function (resultArr) {
|
mopidy.library.lookup({'uris': [resultArr[i].uri]}).then(function (resultDict) {
|
||||||
popupData[resultArr[0].uri] = resultArr[0];
|
var uri = Object.keys(resultDict)[0];
|
||||||
browseTracks.push(resultArr[0]);
|
popupData[uri] = resultDict[uri][0];
|
||||||
|
browseTracks.push(resultDict[uri][0]);
|
||||||
}, console.error);
|
}, console.error);
|
||||||
child += '<li class="song albumli" id="browselisttracks-' + resultArr[i].uri + '">' +
|
child += '<li class="song albumli" id="browselisttracks-' + resultArr[i].uri + '">' +
|
||||||
'<a href="#" class="moreBtn" onclick="return popupTracks(event, \'' + uri + '\', \'' + resultArr[i].uri + '\', \'' + index + '\');">' +
|
'<a href="#" class="moreBtn" onclick="return popupTracks(event, \'' + uri + '\', \'' + resultArr[i].uri + '\', \'' + index + '\');">' +
|
||||||
@ -191,7 +192,7 @@ function processPlaylistItems(resultDict) {
|
|||||||
for (i = 0; i < resultDict.items.length; i++) {
|
for (i = 0; i < resultDict.items.length; i++) {
|
||||||
trackUris.push(resultDict.items[i].uri);
|
trackUris.push(resultDict.items[i].uri);
|
||||||
}
|
}
|
||||||
return mopidy.library.lookup(null, trackUris).then(function(tracks) {
|
return mopidy.library.lookup({'uris': trackUris}).then(function(tracks) {
|
||||||
// Transform from dict to list and cache result
|
// Transform from dict to list and cache result
|
||||||
var newplaylisturi = resultDict.uri;
|
var newplaylisturi = resultDict.uri;
|
||||||
playlists[newplaylisturi] = {'uri':newplaylisturi, 'tracks':[]};
|
playlists[newplaylisturi] = {'uri':newplaylisturi, 'tracks':[]};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
CACHE MANIFEST
|
CACHE MANIFEST
|
||||||
|
|
||||||
# 2016-01-30:v1
|
# 2016-01-31:v1
|
||||||
|
|
||||||
NETWORK:
|
NETWORK:
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user