add Play Next option, fix for 'loading…' bug
This commit is contained in:
parent
d31f97773a
commit
a2b1937a0e
@ -73,17 +73,20 @@
|
||||
<div data-role="popup" data-transition="none" data-theme="c" id="popupTracks">
|
||||
<div data-role="collapsible-set">
|
||||
<ul data-role="listview" data-icon="false" id="popupTracksLv">
|
||||
<!-- <li data-role="divider">
|
||||
Track
|
||||
</li> -->
|
||||
<li>
|
||||
<a href="#" onclick="return playTrack();">Play <span id="popupTrackName"></span></a>
|
||||
<li data-role="divider">
|
||||
<span id="popupTrackName"></span>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" onclick="return playTrack('one');">Add this track to bottom of queue</a>
|
||||
<a href="#" onclick="return playTrack();">Play Now <span id="popupTrackName"></span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" onclick="return playTrack('all');">Add all tracks to bottom of queue</a>
|
||||
<a href="#" onclick="return playTrack(PLAY_NEXT);">Play Track Next</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" onclick="return playTrack(ADD_THIS_BOTTOM);">Add track to bottom of queue</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" onclick="return playTrack(ADD_ALL_BOTTOM);" id="liaddtobottom">Add all tracks to bottom of queue</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" onclick="showAlbumPopup()">Show Album <span id="popupAlbumName"></span></a>
|
||||
|
||||
57
webclient/js/controls.js
vendored
57
webclient/js/controls.js
vendored
@ -1,9 +1,9 @@
|
||||
/********************************************************
|
||||
* play an uri from a trackslist or the current playlist
|
||||
*********************************************************/
|
||||
function playTrack(addtobottom) {
|
||||
function playTrack(addtoqueue) {
|
||||
//stop directly, for user feedback
|
||||
if (!addtobottom) {
|
||||
if (!addtoqueue) {
|
||||
mopidy.playback.stop(true);
|
||||
}
|
||||
$('#popupTracks').popup('close');
|
||||
@ -18,7 +18,7 @@ function playTrack(addtobottom) {
|
||||
var track, tracksbefore, tracksafter;
|
||||
var tracks = getTracksFromUri(playlisturi);
|
||||
if (tracks) {
|
||||
if (!addtobottom) {
|
||||
if (!addtoqueue) {
|
||||
clearQueue();
|
||||
}
|
||||
$(CURRENT_PLAYLIST_TABLE).empty();
|
||||
@ -38,32 +38,39 @@ function playTrack(addtobottom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addtobottom) {
|
||||
if (addtobottom == 'one') {
|
||||
tracks.length = 1;
|
||||
}
|
||||
mopidy.tracklist.add(tracks);
|
||||
showLoading(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// first add track to be played, then the other tracks
|
||||
//find track that was selected
|
||||
for (var i = 0; i < tracks.length; i++) {
|
||||
if (tracks[i].uri == uri) {
|
||||
console.log(i);
|
||||
mopidy.tracklist.add(tracks.slice(i, i + 1) );
|
||||
mopidy.playback.play();
|
||||
//wait 2 seconds before adding the rest to give server the time to start playing
|
||||
setTimeout(function() {
|
||||
mopidy.tracklist.add(tracks.slice(0, i), 0);
|
||||
if (i < tracks.length) {
|
||||
mopidy.tracklist.add(tracks.slice(i + 1) );
|
||||
}
|
||||
}, (2000));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//options
|
||||
switch (addtoqueue) {
|
||||
case ADD_THIS_BOTTOM:
|
||||
mopidy.tracklist.add(tracks.slice(i, i + 1));
|
||||
showLoading(false);
|
||||
return false;
|
||||
case PLAY_NEXT:
|
||||
mopidy.tracklist.add(tracks.slice(i, i + 1), 1);
|
||||
showLoading(false);
|
||||
return false;
|
||||
case ADD_ALL_BOTTOM:
|
||||
mopidy.tracklist.add(tracks);
|
||||
showLoading(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// play now: first add track to be played, then the other tracks
|
||||
mopidy.tracklist.add(tracks.slice(i, i + 1) );
|
||||
mopidy.playback.play();
|
||||
//wait 2 seconds before adding the rest to give server the time to start playing
|
||||
setTimeout(function() {
|
||||
mopidy.tracklist.add(tracks.slice(0, i), 0);
|
||||
if (i < tracks.length) {
|
||||
mopidy.tracklist.add(tracks.slice(i + 1) );
|
||||
}
|
||||
}, (2000));
|
||||
showLoading(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -59,6 +59,11 @@ SEARCH_ALBUM_TABLE = '#albumresulttable';
|
||||
SEARCH_ARTIST_TABLE = '#artistresulttable';
|
||||
SEARCH_TRACK_TABLE = '#trackresulttable';
|
||||
|
||||
PLAY_NOW = 0;
|
||||
PLAY_NEXT = 1;
|
||||
ADD_THIS_BOTTOM = 2;
|
||||
ADD_ALL_BOTTOM = 3;
|
||||
|
||||
MAX_TABLEROWS = 50;
|
||||
|
||||
//update track slider timer, milliseconds
|
||||
@ -78,9 +83,13 @@ function scrollToTop() {
|
||||
}
|
||||
|
||||
function scrollToTracklist() {
|
||||
/* if (isMobileWebkit) {
|
||||
playlistslistScroll.refresh();
|
||||
}
|
||||
*/
|
||||
var divtop = $("#playlisttracksdiv").offset().top - 50;
|
||||
$('body,html').animate({
|
||||
scrollTop : divtop
|
||||
scrollTop : divtop
|
||||
}, 250);
|
||||
}
|
||||
|
||||
@ -109,7 +118,6 @@ function getAlbum(pl) {
|
||||
* break up results and put them in album tables
|
||||
*********************************************************/
|
||||
function albumTracksToTable(pl, target, uri) {
|
||||
console.log(pl);
|
||||
var tmp = '';
|
||||
var targetmin = target.substr(1);
|
||||
$(target).empty();
|
||||
@ -284,10 +292,3 @@ function timeFromSeconds(length) {
|
||||
var s = Math.floor(d % 3600 % 60);
|
||||
return ((h > 0 ? h + ":" : "") + (m > 0 ? (h > 0 && m < 10 ? "0" : "") + m + ":" : "0:") + (s < 10 ? "0" : "") + s);
|
||||
}
|
||||
|
||||
//get hash
|
||||
function getHash() {
|
||||
var hash = document.location.hash.split('?');
|
||||
//remove #
|
||||
return hash[0].substr(1);
|
||||
}
|
||||
@ -62,7 +62,6 @@ function processGetPlaylists(resultArr) {
|
||||
/*<p><ul><li>Donec id elit non mi porta</li><li>Gravida at eget metus. Fusce dapibus.</li><li>Tellus ac cursus commodo</li></p>
|
||||
<p><a class="btn" href="#">More »</a></p>
|
||||
*/
|
||||
|
||||
if ((!resultArr) || (resultArr == '')) {
|
||||
return;
|
||||
}
|
||||
@ -74,9 +73,12 @@ function processGetPlaylists(resultArr) {
|
||||
$('#playlistslist').empty();
|
||||
$('#playlistslist').html(tmp);
|
||||
// $('#playlistslist').listview('refresh');
|
||||
if (isMobileWebkit) {
|
||||
scrollToTracklist();
|
||||
/* if (isMobileWebkit) {
|
||||
playlistslistScroll.refresh();
|
||||
}
|
||||
*/
|
||||
console.log('pl');
|
||||
showLoading(false);
|
||||
}
|
||||
|
||||
@ -109,7 +111,6 @@ function processCurrentPlaylist(resultArr) {
|
||||
* process results of an artist lookup
|
||||
*********************************************************/
|
||||
function processArtistResults(resultArr) {
|
||||
console.log(resultArr);
|
||||
customTracklists[resultArr.uri] = resultArr;
|
||||
|
||||
resultsToTables(resultArr, ARTIST_TABLE, resultArr.uri);
|
||||
@ -124,7 +125,6 @@ function processArtistResults(resultArr) {
|
||||
* process results of an album lookup
|
||||
*********************************************************/
|
||||
function processAlbumResults(resultArr) {
|
||||
console.log(resultArr);
|
||||
customTracklists[resultArr.uri] = resultArr;
|
||||
albumTracksToTable(resultArr, ALBUM_TABLE, resultArr.uri);
|
||||
var albumname = getAlbum(resultArr);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user