fix:Use explicit Mopidy.js calling convention.
This commit is contained in:
parent
1a9070fbe5
commit
a9338a6ec8
@ -103,6 +103,7 @@ v2.1.0 (UNRELEASED)
|
||||
- Fix vertical alignment of playback control buttons in footer.
|
||||
- Increase width of header so that more text can be rendered in the title bar.
|
||||
(Fixes: `#144 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/144>`_).
|
||||
- Use explicit Mopidy.js calling convention. (Fixes: `#79 <https://github.com/pimusicbox/mopidy-musicbox-webclient/issues/79>`_).
|
||||
|
||||
|
||||
v2.0.0 (2015-03-26)
|
||||
|
||||
122
mopidy_musicbox_webclient/static/js/controls.js
vendored
122
mopidy_musicbox_webclient/static/js/controls.js
vendored
@ -1,6 +1,6 @@
|
||||
/********************************************************
|
||||
* play tracks from a browse list
|
||||
*********************************************************/
|
||||
/***********************************
|
||||
* play tracks from a browse list *
|
||||
***********************************/
|
||||
function playBrowsedTracks(action, trackIndex) {
|
||||
$('#popupBrowse').popup('close');
|
||||
toast('Loading...');
|
||||
@ -32,7 +32,7 @@ function playBrowsedTracks(action, trackIndex) {
|
||||
var maybePlay = function(tlTracks) {
|
||||
if (action === PLAY_NOW || action === PLAY_ALL) {
|
||||
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_NEXT:
|
||||
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;
|
||||
case ADD_THIS_BOTTOM:
|
||||
case ADD_ALL_BOTTOM:
|
||||
case PLAY_ALL:
|
||||
mopidy.tracklist.add(null, null, null, trackUris).then(maybePlay);
|
||||
mopidy.tracklist.add({'uris': trackUris}).then(maybePlay);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -54,10 +54,9 @@ function playBrowsedTracks(action, trackIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
* play an uri from a tracklist
|
||||
*********************************************************/
|
||||
/*********************************
|
||||
* play an uri from a tracklist *
|
||||
*********************************/
|
||||
function playTrack(action) {
|
||||
var hash = document.location.hash.split('?');
|
||||
var divid = hash[0].substr(1);
|
||||
@ -92,21 +91,21 @@ function playTrack(action) {
|
||||
case PLAY_NOW:
|
||||
case PLAY_NOW_SEARCH:
|
||||
mopidy.tracklist.clear().then(
|
||||
mopidy.tracklist.add(null, null, null, trackUris).then(
|
||||
mopidy.tracklist.add({'uris': trackUris}).then(
|
||||
function(tlTracks) {
|
||||
mopidy.playback.play(tlTracks[selected])
|
||||
mopidy.playback.play({'tl_track': tlTracks[selected]})
|
||||
}
|
||||
)
|
||||
);
|
||||
break;
|
||||
case PLAY_NEXT:
|
||||
mopidy.tracklist.index().then(function(currentIndex) {
|
||||
mopidy.tracklist.add(null, currentIndex + 1, null, trackUris);
|
||||
mopidy.tracklist.add({'at_position': currentIndex + 1, 'uris': trackUris});
|
||||
});
|
||||
break;
|
||||
case ADD_THIS_BOTTOM:
|
||||
case ADD_ALL_BOTTOM:
|
||||
mopidy.tracklist.add(null, null, null, trackUris);
|
||||
mopidy.tracklist.add({'uris': trackUris});
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
@ -123,7 +122,7 @@ function playTrackByUri(track_uri, playlist_uri) {
|
||||
// Find track that was selected
|
||||
for (var selected = 0; selected < tltracks.length; selected++) {
|
||||
if (tltracks[selected].track.uri == track_uri) {
|
||||
mopidy.playback.play(tltracks[selected]);
|
||||
mopidy.playback.play({'tl_track': tltracks[selected]});
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -142,11 +141,11 @@ function playTrackByUri(track_uri, playlist_uri) {
|
||||
|
||||
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.
|
||||
if (tltracks.length == 0) {
|
||||
var trackUris = getTracksFromUri(playlist_uri, false);
|
||||
mopidy.tracklist.add(null, null, null, trackUris).then(findAndPlayTrack);
|
||||
mopidy.tracklist.add({'uris': trackUris}).then(findAndPlayTrack);
|
||||
} else {
|
||||
findAndPlayTrack(tltracks);
|
||||
}
|
||||
@ -165,7 +164,6 @@ function playTrackByUri(track_uri, playlist_uri) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function playTrackQueueByTlid(uri, tlid) {
|
||||
// console.log('playquuri');
|
||||
//stop directly, for user feedback
|
||||
mopidy.playback.stop();
|
||||
$('#popupQueue').popup('close');
|
||||
@ -177,7 +175,7 @@ function playTrackQueueByTlid(uri, tlid) {
|
||||
}).then(
|
||||
function(tltracks) {
|
||||
if (tltracks.length > 0) {
|
||||
mopidy.playback.play(tltracks[0]);
|
||||
mopidy.playback.play({'tl_track': tltracks[0]});
|
||||
return;
|
||||
}
|
||||
console.log('Failed to play selected track ', tlid);
|
||||
@ -191,22 +189,21 @@ function playTrackQueueByTlid(uri, tlid) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function playTrackQueue() {
|
||||
// console.log('playqu');
|
||||
uri = $('#popupQueue').data("track");
|
||||
tlid = $('#popupQueue').data("tlid");
|
||||
return playTrackQueueByTlid(uri, tlid);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* remove a track from the queue
|
||||
*********************************************************/
|
||||
/***********************************
|
||||
* remove a track from the queue *
|
||||
***********************************/
|
||||
function removeTrack() {
|
||||
$('#popupQueue').popup('close');
|
||||
toast('Deleting...');
|
||||
|
||||
tlid = parseInt($('#popupQueue').data("tlid"));
|
||||
console.log(tlid);
|
||||
mopidy.tracklist.remove({'tlid':[tlid]});
|
||||
mopidy.tracklist.remove({'tlid': [tlid]});
|
||||
}
|
||||
|
||||
function clearQueue() {
|
||||
@ -228,9 +225,9 @@ function saveQueue() {
|
||||
exists = exists || existing[i].uri.indexOf("m3u:") == 0 || existing[i].uri.indexOf("local:") == 0;
|
||||
}
|
||||
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;
|
||||
mopidy.playlists.save(playlist).then();
|
||||
mopidy.playlists.save({'playlist': playlist}).then();
|
||||
getPlaylists();
|
||||
});
|
||||
}
|
||||
@ -241,15 +238,14 @@ function saveQueue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function refreshPlaylists() {
|
||||
mopidy.playlists.refresh();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* Buttons
|
||||
*/
|
||||
/*************
|
||||
* Buttons *
|
||||
*************/
|
||||
|
||||
function doShuffle() {
|
||||
mopidy.playback.stop();
|
||||
@ -303,10 +299,9 @@ function backbt() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/***************
|
||||
* Options
|
||||
***************/
|
||||
|
||||
/*************
|
||||
* Options *
|
||||
*************/
|
||||
function setTracklistOption(name, new_value) {
|
||||
if (!new_value) {
|
||||
$("#"+name+"bt").attr('style', 'color:#2489ce');
|
||||
@ -341,27 +336,26 @@ function setSingle(nwsingle) {
|
||||
}
|
||||
|
||||
function doRandom() {
|
||||
mopidy.tracklist.setRandom(!random).then();
|
||||
mopidy.tracklist.setRandom({'value': !random}).then();
|
||||
}
|
||||
|
||||
function doRepeat() {
|
||||
mopidy.tracklist.setRepeat(!repeat).then();
|
||||
mopidy.tracklist.setRepeat({'value': !repeat}).then();
|
||||
}
|
||||
|
||||
function doConsume() {
|
||||
mopidy.tracklist.setConsume(!consume).then();
|
||||
mopidy.tracklist.setConsume({'value': !consume}).then();
|
||||
}
|
||||
|
||||
function doSingle() {
|
||||
mopidy.tracklist.setSingle(!single).then();
|
||||
mopidy.tracklist.setSingle({'value': !single}).then();
|
||||
}
|
||||
|
||||
|
||||
/*********************
|
||||
* Track Slider
|
||||
* Use a timer to prevent looping of commands
|
||||
*********************/
|
||||
|
||||
/***********************************************
|
||||
* Track Slider *
|
||||
* Use a timer to prevent looping of commands *
|
||||
***********************************************/
|
||||
function doSeekPos(value) {
|
||||
var val = $("#trackslider").val();
|
||||
newposition = Math.round(val);
|
||||
@ -377,10 +371,7 @@ function doSeekPos(value) {
|
||||
function triggerPos() {
|
||||
if (mopidy) {
|
||||
posChanging = true;
|
||||
// mopidy.playback.pause();
|
||||
// console.log(newposition);
|
||||
mopidy.playback.seek(newposition);
|
||||
// mopidy.playback.resume();
|
||||
mopidy.playback.seek({'time_position': newposition});
|
||||
resumePosTimer();
|
||||
posChanging = false;
|
||||
}
|
||||
@ -402,10 +393,10 @@ function setPosition(pos) {
|
||||
$("#songelapsed").html(timeFromSeconds(currentposition / 1000));
|
||||
}
|
||||
|
||||
/********************
|
||||
* Volume slider
|
||||
* Use a timer to prevent looping of commands
|
||||
*/
|
||||
/***********************************************
|
||||
* Volume slider *
|
||||
* Use a timer to prevent looping of commands *
|
||||
***********************************************/
|
||||
|
||||
function setVolume(value) {
|
||||
if ($("#volumeslider").val() != value) {
|
||||
@ -420,7 +411,7 @@ function doVolume(value) {
|
||||
}
|
||||
|
||||
function triggerVolume() {
|
||||
mopidy.playback.setVolume(parseInt(volumeChanging));
|
||||
mopidy.playback.setVolume({'volume': parseInt(volumeChanging)});
|
||||
volumeChanging = 0;
|
||||
}
|
||||
|
||||
@ -436,18 +427,17 @@ function setMute(nwmute) {
|
||||
}
|
||||
|
||||
function doMute() {
|
||||
mopidy.mixer.setMute(!mute);
|
||||
mopidy.mixer.setMute({'mute': !mute});
|
||||
}
|
||||
|
||||
/*******
|
||||
* Track position timer
|
||||
*/
|
||||
/**************************
|
||||
* Track position timer *
|
||||
**************************/
|
||||
|
||||
//timer function to update interface
|
||||
function updatePosTimer() {
|
||||
currentposition += TRACK_TIMER;
|
||||
setPosition(currentposition);
|
||||
// $("#songelapsed").html(timeFromSeconds(currentposition / 1000));
|
||||
}
|
||||
|
||||
function resumePosTimer() {
|
||||
@ -467,9 +457,9 @@ function pausePosTimer() {
|
||||
clearInterval(posTimer);
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* Stream
|
||||
*********************************/
|
||||
/************
|
||||
* Stream *
|
||||
************/
|
||||
function streamPressed(key) {
|
||||
if (key == 13) {
|
||||
playStreamUri();
|
||||
@ -493,7 +483,7 @@ function playStreamUri(uri) {
|
||||
document.activeElement.blur();
|
||||
clearQueue();
|
||||
$("input").blur();
|
||||
mopidy.tracklist.add(null, null, nwuri);
|
||||
mopidy.tracklist.add({'uris': [nwuri]});
|
||||
mopidy.playback.play();
|
||||
} else {
|
||||
toast('No valid url!');
|
||||
@ -524,7 +514,7 @@ function getPlaylistByName(name, scheme, 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);
|
||||
return plist;
|
||||
});
|
||||
@ -534,7 +524,7 @@ function getPlaylistByName(name, scheme, create) {
|
||||
}
|
||||
|
||||
function getPlaylistFull(uri) {
|
||||
return mopidy.playlists.lookup(uri).then(function(pl) {
|
||||
return mopidy.playlists.lookup({'uri': uri}).then(function(pl) {
|
||||
playlists[uri] = pl;
|
||||
return pl;
|
||||
});
|
||||
@ -551,7 +541,7 @@ function getFavourites() {
|
||||
function addFavourite(uri, name) {
|
||||
var uri = uri || $('#streamuriinput').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];
|
||||
if (newTracks.length == 1) {
|
||||
// TODO: Supporting adding an entire playlist?
|
||||
@ -566,7 +556,7 @@ function addFavourite(uri, name) {
|
||||
} else {
|
||||
favourites.tracks = [newTracks[0]];
|
||||
}
|
||||
mopidy.playlists.save(favourites).then(function(s) {
|
||||
mopidy.playlists.save({'playlist': favourites}).then(function(s) {
|
||||
showFavourites();
|
||||
});
|
||||
}
|
||||
@ -587,7 +577,7 @@ function deleteFavourite(index) {
|
||||
var name = favourites.tracks[index].name;
|
||||
if (confirm("Are you sure you want to remove '" + name + "'?")) {
|
||||
favourites.tracks.splice(index, 1);
|
||||
mopidy.playlists.save(favourites).then(function(s) {
|
||||
mopidy.playlists.save({'playlist': favourites}).then(function(s) {
|
||||
showFavourites();
|
||||
});
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ var songlength = 0;
|
||||
var artistshtml = '';
|
||||
var artiststext = '';
|
||||
var songname = '';
|
||||
var songdata = {'track':{}, 'tlid':-1};
|
||||
var songdata = {'track': {}, 'tlid': -1};
|
||||
var newposition = 0;
|
||||
|
||||
var playlisttracksScroll;
|
||||
@ -53,7 +53,6 @@ var ua = navigator.userAgent,
|
||||
|
||||
//constants
|
||||
PROGRAM_NAME = 'MusicBox';
|
||||
//PROGRAM_NAME = 'Mopidy';
|
||||
ARTIST_TABLE = '#artiststable';
|
||||
ALBUM_TABLE = '#albumstable';
|
||||
PLAYLIST_TABLE = '#playlisttracks';
|
||||
@ -127,10 +126,6 @@ function scrollToTop() {
|
||||
}
|
||||
|
||||
function scrollToTracklist() {
|
||||
/* if (isMobileWebkit) {
|
||||
playlistslistScroll.refresh();
|
||||
}
|
||||
*/
|
||||
var divtop = $("#playlisttracksdiv").offset().top - 120;
|
||||
$('body,html').animate({
|
||||
scrollTop: divtop
|
||||
@ -198,12 +193,10 @@ function renderSongLi(song, liID, uri) {
|
||||
} else {
|
||||
name = song.name;
|
||||
}
|
||||
// var iconClass = getMediaClass(liID.split('-')[1]);
|
||||
songLi = '<li class="song albumli" id="' + liID + '">' +
|
||||
'<a href="#" class="moreBtn" onclick="return popupTracks(event, \'' + uri + '\',\'' + song.uri + '\');">' +
|
||||
'<i class="fa fa-ellipsis-v"></i></a>' +
|
||||
'<a href="#" onclick="return playTrackByUri(\'' + song.uri + '\',\'' + uri + '\');">' +
|
||||
// '<h1 class="trackname"><i class="' + iconClass + '"></i> ' + name + '</h1>' +
|
||||
'<h1 class="trackname">' + name + '</h1></a>' +
|
||||
'</li>';
|
||||
return songLi;
|
||||
@ -217,12 +210,10 @@ function renderQueueSongLi(song, liID, uri, tlid) {
|
||||
} else {
|
||||
name = song.name;
|
||||
}
|
||||
// var iconClass = getMediaClass(liID.split('-')[1]);
|
||||
songLi = '<li class="song albumli" id="' + liID + '" tlid="' + tlid + '">' +
|
||||
'<a href="#" class="moreBtn" onclick="return popupTracks(event, \'' + uri + '\',\'' + song.uri + '\',\'' + tlid + '\');">' +
|
||||
'<i class="fa fa-ellipsis-v"></i></a>' +
|
||||
'<a href="#" onclick="return playTrackQueueByTlid(\'' + song.uri + '\',\'' + tlid + '\');">' +
|
||||
// '<h1 class="trackname"><i class="' + iconClass + '"></i> ' + name + '</h1>' +
|
||||
'<h1 class="trackname">' + name + '</h1></a>' +
|
||||
'</li>';
|
||||
return songLi;
|
||||
@ -310,7 +301,6 @@ function resultsToTables(results, target, uri) {
|
||||
'<h1><i class="' + iconClass + '"></i> ' + newalbum[0].name + "</h1><p>";
|
||||
}
|
||||
|
||||
/* '<span style="float: right;">' + timeFromSeconds(newalbum[0].length / 1000) + '</span>'; */
|
||||
if (newalbum[0].artists) {
|
||||
for (j = 0; j < newalbum[0].artists.length; j++) {
|
||||
html += newalbum[0].artists[j].name;
|
||||
@ -333,7 +323,6 @@ function resultsToTables(results, target, uri) {
|
||||
newtlids = [];
|
||||
} else { //newalbum length
|
||||
if (results[i].album.uri && results[i].album.name) {
|
||||
// iconClass = getMediaClass(results[i].album.uri);
|
||||
iconClass = getMediaClass(newalbum[0].uri);
|
||||
html += '<li class="albumdivider">';
|
||||
html += '<a href="#" onclick="return showAlbum(\'' + results[i].album.uri + '\');"><img id="' +
|
||||
@ -353,8 +342,6 @@ function resultsToTables(results, target, uri) {
|
||||
html += '</p></a></li>';
|
||||
for (j = 0; j < newalbum.length; j++) {
|
||||
popupData[newalbum[j].uri] = newalbum[j];
|
||||
// html += '<li class="albumli" id="' + targetmin + '-' + newalbum[j].uri + '"><a href="#" onclick="return ' + popupMenu + '(event, \'' + uri + '\',\'' + newalbum[j].uri + '\');">';
|
||||
|
||||
//hERE!
|
||||
var liID = targetmin + '-' + newalbum[j].uri;
|
||||
if (target == CURRENT_PLAYLIST_TABLE) {
|
||||
@ -362,9 +349,6 @@ function resultsToTables(results, target, uri) {
|
||||
} else {
|
||||
html += renderSongLi(newalbum[j], liID, uri);
|
||||
}
|
||||
|
||||
//html += '<li class="albumli" id="' + targetmin + '-' + newalbum[j].uri + '"><a href="#" onclick="return popupTracks(event, \'' + uri + '\',\'' + newalbum[j].uri + '\');">';
|
||||
//html += '<p class="pright">' + timeFromSeconds(newalbum[j].length / 1000) + '</p><h1>' + newalbum[j].name + '</h1></a></li>';
|
||||
}
|
||||
newalbum = [];
|
||||
newtlids = [];
|
||||
@ -383,7 +367,6 @@ function resultsToTables(results, target, uri) {
|
||||
$(target).attr('data', uri);
|
||||
//retreive albumcovers
|
||||
for (i = 0; i < coversList.length; i++) {
|
||||
// console.log(coversList[i]);
|
||||
getCover(coversList[i][0], target + '-cover-' + coversList[i][1], 'small');
|
||||
}
|
||||
}
|
||||
@ -401,7 +384,6 @@ function playlisttotable(pl, target, uri) {
|
||||
child += '<h1>' + pl[i].name + "</h1>";
|
||||
child += '<p>';
|
||||
child += '<span style="float: right;">' + timeFromSeconds(pl[i].length / 1000) + '</span>';
|
||||
// <span class="ui-icon ui-icon-arrow-r ui-icon-shadow"> </span>
|
||||
for (var j = 0; j < pl[i].artists.length; j++) {
|
||||
if (pl[i].artists[j]) {
|
||||
child += pl[i].artists[j].name;
|
||||
@ -428,7 +410,7 @@ function getPlaylistTracks(uri) {
|
||||
return Mopidy.when(playlists[uri].tracks);
|
||||
} else {
|
||||
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});
|
||||
}, console.error);
|
||||
}
|
||||
@ -463,7 +445,6 @@ function timeFromSeconds(length) {
|
||||
return ((h > 0 ? h + ":" : "") + (m > 0 ? (h > 0 && m < 10 ? "0" : "") + m + ":" : "0:") + (s < 10 ? "0" : "") + s);
|
||||
}
|
||||
|
||||
|
||||
/******* Toast ***/
|
||||
function toast(message, delay, textOnly) {
|
||||
textOnl = textOnly || false;
|
||||
@ -482,9 +463,9 @@ function toast(message, delay, textOnly) {
|
||||
}
|
||||
}
|
||||
|
||||
/*****************
|
||||
* Modal dialogs
|
||||
*****************/
|
||||
/******************
|
||||
* Modal dialogs *
|
||||
******************/
|
||||
function showLoading(on) {
|
||||
if (on) {
|
||||
$("body").css("cursor", "progress");
|
||||
@ -515,7 +496,6 @@ function showOffline(on) {
|
||||
// from http://dzone.com/snippets/validate-url-regexp
|
||||
function validUri(str) {
|
||||
var regexp = /^(mms|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
|
||||
// return regexp.test(str) || isServiceUri(str);
|
||||
return regexp.test(str);
|
||||
}
|
||||
|
||||
|
||||
@ -483,10 +483,11 @@ $(document).ready(function(event) {
|
||||
// Connect to server
|
||||
if (websocketUrl) {
|
||||
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 {
|
||||
mopidy = new Mopidy();
|
||||
mopidy = new Mopidy({callingConvention: "by-position-or-by-name"});
|
||||
}
|
||||
// mopidy.on(console.log.bind(console)); // Log all events
|
||||
// mopidy.on(console.error.bind(console));
|
||||
|
||||
@ -2,14 +2,13 @@
|
||||
* @author Wouter van Wijk
|
||||
*/
|
||||
|
||||
API_KEY= 'b6d34c3af91d62ab0ae00ab1b6fa8733';
|
||||
API_KEY = 'b6d34c3af91d62ab0ae00ab1b6fa8733';
|
||||
API_SECRET = '2c631802c2285d5d5d1502462fe42a2b';
|
||||
|
||||
var fmcache;
|
||||
var lastfm;
|
||||
|
||||
|
||||
$(window).load(function() {
|
||||
$(window).load(function () {
|
||||
// create a Cache object
|
||||
fmcache = new LastFMCache();
|
||||
// create a LastFM object
|
||||
@ -20,42 +19,40 @@ $(window).load(function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function getCover(album, images, size) {
|
||||
var defUrl = 'images/default_cover.png';
|
||||
$(images).attr('src', defUrl);
|
||||
if (!album) {
|
||||
return;
|
||||
}
|
||||
var albumname = album.name || '';
|
||||
var artistname = '';
|
||||
if ( album.artists && (album.artists.length > 0) ) {
|
||||
artistname = album.artists[0].name;
|
||||
}
|
||||
// console.log(album, images);
|
||||
if (album.images && (album.images.length > 0) ) {
|
||||
$(images).attr('src', album.images[0]);
|
||||
} else {
|
||||
lastfm.album.getInfo( {artist: artistname, album: albumname},
|
||||
{ success: function(data){
|
||||
for (var i = 0; i < data.album.image.length; i++) {
|
||||
if ( data.album.image[i]['size'] == size) {
|
||||
$(images).attr('src', data.album.image[i]['#text'] || defUrl);
|
||||
}
|
||||
var defUrl = 'images/default_cover.png';
|
||||
$(images).attr('src', defUrl);
|
||||
if (!album) {
|
||||
return;
|
||||
}
|
||||
var albumname = album.name || '';
|
||||
var artistname = '';
|
||||
if ( album.artists && (album.artists.length > 0) ) {
|
||||
artistname = album.artists[0].name;
|
||||
}
|
||||
if (album.images && (album.images.length > 0) ) {
|
||||
$(images).attr('src', album.images[0]);
|
||||
} else {
|
||||
lastfm.album.getInfo( {artist: artistname, album: albumname},
|
||||
{ success: function(data){
|
||||
for (var i = 0; i < data.album.image.length; i++) {
|
||||
if ( data.album.image[i]['size'] == size) {
|
||||
$(images).attr('src', data.album.image[i]['#text'] || defUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getArtistImage(nwartist, image, size) {
|
||||
var defUrl = 'images/user_24x32.png';
|
||||
lastfm.artist.getInfo({artist: nwartist}, {success: function(data){
|
||||
for (var i = 0; i < data.artist.image.length; i++) {
|
||||
if ( data.artist.image[i]['size'] == size) {
|
||||
$(image).attr('src', data.artist.image[i]['#text'] || defUrl);
|
||||
}
|
||||
var defUrl = 'images/user_24x32.png';
|
||||
lastfm.artist.getInfo({artist: nwartist}, {success: function(data){
|
||||
for (var i = 0; i < data.artist.image.length; i++) {
|
||||
if ( data.artist.image[i]['size'] == size) {
|
||||
$(image).attr('src', data.artist.image[i]['#text'] || defUrl);
|
||||
}
|
||||
}});
|
||||
}
|
||||
}});
|
||||
}
|
||||
@ -30,7 +30,7 @@ function initSearch() {
|
||||
$("#searchresults").hide();
|
||||
|
||||
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 {
|
||||
mopidy.getUriSchemes().then(function (schemes) {
|
||||
var query = {},
|
||||
@ -48,7 +48,7 @@ function initSearch() {
|
||||
} else {
|
||||
query = {any: [value]};
|
||||
}
|
||||
mopidy.library.search(query, uris).then(processSearchResults, console.error);
|
||||
mopidy.library.search({'query': query, 'uris': uris}).then(processSearchResults, console.error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -79,15 +79,6 @@ function processSearchResults(resultArr) {
|
||||
var results = {'tracks': [], 'artists': [], 'albums': []};
|
||||
var j, emptyResult = true;
|
||||
|
||||
/* for (var i = 0; i < resultArr.length; ++i) {
|
||||
for (var prop in results) {
|
||||
if (resultArr[i][prop] && resultArr[i][prop].length) {
|
||||
results[prop] = results[prop].concat(resultArr[i][prop]);
|
||||
emptyResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (var i = 0; i < resultArr.length; i++) {
|
||||
if (resultArr[i].tracks) {
|
||||
for (j = 0; j < resultArr[i].tracks.length; j++) {
|
||||
@ -109,10 +100,6 @@ function processSearchResults(resultArr) {
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(resultArr, results);
|
||||
|
||||
|
||||
|
||||
customTracklists[URI_SCHEME+':trackresultscache'] = results.tracks;
|
||||
|
||||
if (emptyResult) {
|
||||
@ -196,7 +183,6 @@ function processSearchResults(resultArr) {
|
||||
$('#expandsearch').show();
|
||||
|
||||
// Track results
|
||||
// playlisttotable(results.tracks, SEARCH_TRACK_TABLE, URI_SCHEME+':trackresultscache');
|
||||
resultsToTables(results.tracks, SEARCH_TRACK_TABLE, URI_SCHEME+':trackresultscache');
|
||||
|
||||
showLoading(false);
|
||||
@ -225,7 +211,7 @@ function getBrowseDir(rootdir) {
|
||||
} else {
|
||||
browseStack.push(rootdir);
|
||||
}
|
||||
mopidy.library.browse(rootdir).then(processBrowseDir, console.error);
|
||||
mopidy.library.browse({'uri': rootdir}).then(processBrowseDir, console.error);
|
||||
}
|
||||
|
||||
function getCurrentPlaylist() {
|
||||
@ -261,7 +247,6 @@ function showTracklist(uri) {
|
||||
$(this).addClass('playlistactive');
|
||||
}
|
||||
});
|
||||
// scrollToTracklist();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -274,12 +259,11 @@ function showArtist(nwuri) {
|
||||
$('#popupTracks').popup('close');
|
||||
$('#controlsmodal').popup('close');
|
||||
$(ARTIST_TABLE).empty();
|
||||
//fill from cache
|
||||
// var pl = getTracksFromUri(nwuri);
|
||||
|
||||
//TODO cache
|
||||
$('#h_artistname').html('');
|
||||
showLoading(true);
|
||||
mopidy.library.lookup(nwuri).then(function(resultArr) {
|
||||
mopidy.library.lookup({'uris': [nwuri]}).then(function(resultArr) {
|
||||
resultArr.uri = nwuri;
|
||||
processArtistResults(resultArr);
|
||||
}, console.error);
|
||||
@ -304,16 +288,15 @@ function showAlbum(uri) {
|
||||
$('#coverpopupalbumname').html(albumname);
|
||||
$('#coverpopupartist').html(artistname);
|
||||
showLoading(false);
|
||||
mopidy.library.lookup(uri).then(function(resultArr) {
|
||||
mopidy.library.lookup({'uris': [uri]}).then(function(resultArr) {
|
||||
resultArr.uri = uri;
|
||||
processAlbumResults(resultArr);
|
||||
}, console.error);
|
||||
// getCover(pl, '#albumviewcover, #coverpopupimage', 'extralarge');
|
||||
} else {
|
||||
showLoading(true);
|
||||
$('#h_albumname').html('');
|
||||
$('#h_albumartist').html('');
|
||||
mopidy.library.lookup(uri).then(function(resultArr) {
|
||||
mopidy.library.lookup({'uris': [uri]}).then(function(resultArr) {
|
||||
resultArr.uri = uri;
|
||||
processAlbumResults(resultArr);
|
||||
}, console.error);
|
||||
|
||||
@ -118,7 +118,7 @@ function processBrowseDir(resultArr) {
|
||||
iconClass = getMediaClass(resultArr[i].uri);
|
||||
if (resultArr[i].type == 'track') {
|
||||
//console.log(resultArr[i]);
|
||||
mopidy.library.lookup(resultArr[i].uri).then(function (resultArr) {
|
||||
mopidy.library.lookup({'uris': [resultArr[i].uri]}).then(function (resultArr) {
|
||||
popupData[resultArr[0].uri] = resultArr[0];
|
||||
browseTracks.push(resultArr[0]);
|
||||
}, console.error);
|
||||
@ -139,14 +139,6 @@ function processBrowseDir(resultArr) {
|
||||
|
||||
$('#browselist').html(child);
|
||||
if (browseStack.length > 0 ) {
|
||||
/* child = '';
|
||||
for (var i = 0; i < browseStack.length; i++) {
|
||||
child += browseStack[i] + ' / ';
|
||||
}
|
||||
|
||||
child = getMediaHuman(browseStack[0]);
|
||||
iconClass = getMediaClass(browseStack[0]);
|
||||
*/
|
||||
child = getMediaHuman(resultArr[0].uri);
|
||||
iconClass = getMediaClass(resultArr[0].uri);
|
||||
$('#browsepath').html('<i class="' + iconClass + '"></i> ' + child);
|
||||
@ -199,7 +191,7 @@ function processPlaylistItems(resultDict) {
|
||||
for (i = 0; i < resultDict.items.length; i++) {
|
||||
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
|
||||
var newplaylisturi = resultDict.uri;
|
||||
playlists[newplaylisturi] = {'uri':newplaylisturi, 'tracks':[]};
|
||||
|
||||
@ -6,12 +6,12 @@
|
||||
|
||||
var streamUris = [];
|
||||
//fill with defaults
|
||||
streamUris.push(['NPR 24', 'http://nprdmp.ic.llnwd.net/stream/nprdmp_live01_mp3']);
|
||||
streamUris.push(['3FM Dutch', 'http://icecast.omroep.nl/3fm-bb-mp3']);
|
||||
streamUris.push(['BBC WorldService', 'http://vprbbc.streamguys.net:8000/vprbbc24.mp3']);
|
||||
streamUris.push(['Arrow Jazz', 'http://81.173.3.132:8082']);
|
||||
streamUris.push(['Queen Live Aid at Wembley (YouTube)', 'yt:http://www.youtube.com/watch?v=eQsM6u0a038']);
|
||||
streamUris.push(['Groove Salad - Soma FM', 'http://somafm.com/groovesalad.pls']);
|
||||
streamUris.push(['Kiss FM Berlin', 'http://stream.kissfm.de/kissfm/mp3-128/internetradio/']);
|
||||
streamUris.push(['Muse - Newborn (SoundCloud)', 'sc:https://soundcloud.com/muse/01-new-born']);
|
||||
streamUris.push(['Pinguin Radio', 'http://pr320.pinguinradio.com/listen.pls']);
|
||||
streamUris.push(['NPR 24', 'http://nprdmp.ic.llnwd.net/stream/nprdmp_live01_mp3']);
|
||||
streamUris.push(['3FM Dutch', 'http://icecast.omroep.nl/3fm-bb-mp3']);
|
||||
streamUris.push(['BBC WorldService', 'http://vprbbc.streamguys.net:8000/vprbbc24.mp3']);
|
||||
streamUris.push(['Arrow Jazz', 'http://81.173.3.132:8082']);
|
||||
streamUris.push(['Queen Live Aid at Wembley (YouTube)', 'yt:http://www.youtube.com/watch?v=eQsM6u0a038']);
|
||||
streamUris.push(['Groove Salad - Soma FM', 'http://somafm.com/groovesalad.pls']);
|
||||
streamUris.push(['Kiss FM Berlin', 'http://stream.kissfm.de/kissfm/mp3-128/internetradio/']);
|
||||
streamUris.push(['Muse - Newborn (SoundCloud)', 'sc:https://soundcloud.com/muse/01-new-born']);
|
||||
streamUris.push(['Pinguin Radio', 'http://pr320.pinguinradio.com/listen.pls']);
|
||||
Loading…
Reference in New Issue
Block a user