Artists
@@ -200,7 +201,7 @@
-
+
diff --git a/webclient/js/controls.js b/webclient/js/controls.js
index d57a0fb..828cd1a 100644
--- a/webclient/js/controls.js
+++ b/webclient/js/controls.js
@@ -37,6 +37,8 @@ function playTrack() {
return false;
}
+
+
/**********************
* Buttons
*/
@@ -151,6 +153,10 @@ function triggerPos() {
function setPosition(pos) {
var oldval = initgui;
+ if (pos > songlength) {
+ pos = songlength;
+ pauseTimer();
+ }
currentposition = pos;
initgui = true;
$("#trackslider").val(currentposition).slider('refresh');
@@ -172,7 +178,7 @@ function setVolume(value) {
function doVolume(value) {
if (!initgui) {
console.log('volume: ' + value);
- mopidy.playback.setVolume(value);
+ mopidy.playback.setVolume(parseInt(value));
}
}
@@ -188,4 +194,32 @@ function doMute() {
muteVolume = -1;
}
-}
\ No newline at end of file
+}
+/*******
+ * Track timer
+ */
+
+//timer function to update interface
+function updateTimer() {
+ currentposition += TRACK_TIMER;
+ setPosition(currentposition);
+ // $("#songelapsed").html(timeFromSeconds(currentposition / 1000));
+}
+
+function resumeTimer() {
+ pauseTimer();
+ posTimer = setInterval(updateTimer, TRACK_TIMER);
+}
+
+function initTimer() {
+ pauseTimer();
+ // setPosition(0);
+ resumeTimer();
+}
+
+function pauseTimer() {
+ clearInterval(posTimer);
+}
+
+
+
diff --git a/webclient/js/functionsvars.js b/webclient/js/functionsvars.js
index 17b7013..bf9e1a7 100755
--- a/webclient/js/functionsvars.js
+++ b/webclient/js/functionsvars.js
@@ -23,6 +23,7 @@ var seekTimer;
var initgui = true;
var currentpos = 0;
var popupData = {};
+var songlength = 0;
var artistshtml = '';
var artiststext = '';
@@ -36,7 +37,8 @@ var customPlaylists = [];
var customTracklists = [];
//constants
-PROGRAM_NAME = 'Mopidy';
+PROGRAM_NAME = 'MusicBox';
+//PROGRAM_NAME = 'Mopidy';
ARTIST_TABLE = '#artiststable';
ALBUM_TABLE = '#albumstable';
PLAYLIST_TABLE = '#playlisttable';
@@ -45,9 +47,14 @@ SEARCH_ALL_TABLE = '#allresulttable';
SEARCH_ALBUM_TABLE = '#albumresulttable';
SEARCH_ARTIST_TABLE = '#artistresulttable';
SEARCH_TRACK_TABLE = '#trackresulttable';
-//update track timer, milliseconds
+
+//update track slider timer, milliseconds
TRACK_TIMER = 1000;
+//check status timer, every 5 or 10 sec
+STATUS_TIMER = 10000;
+
+
/*******
*
*/
diff --git a/webclient/js/gui.js b/webclient/js/gui.js
index ceb4e20..c521454 100755
--- a/webclient/js/gui.js
+++ b/webclient/js/gui.js
@@ -74,6 +74,7 @@ function setSongInfo(data) {
$("#modalartist").html(arttmp + ': ' + artistshtml);
$("#trackslider").attr("min", 0);
+ songlength = data.length;
$("#trackslider").attr("max", data.length);
$("#songlength").html(timeFromSeconds(data.length / 1000));
@@ -232,39 +233,11 @@ function initSocketevents() {
});
}
-/*******
- * Track timer
- */
-
-//timer function to update interface
-function updateTimer() {
- currentposition += TRACK_TIMER;
- setPosition(currentposition);
- // $("#songelapsed").html(timeFromSeconds(currentposition / 1000));
-}
-
-function resumeTimer() {
- pauseTimer();
- posTimer = setInterval(updateTimer, TRACK_TIMER);
-}
-
-function initTimer() {
- pauseTimer();
- // setPosition(0);
- resumeTimer();
-}
-
-function pauseTimer() {
- clearInterval(posTimer);
-}
-
-
-
/**********************
* initialize software
**********************/
-//$(document).ready(function() {
-$(document).bind("pageinit", function() {
+$(document).ready(function() {
+//$(document).bind("pageinit", function() {
$(window).hashchange();
@@ -273,14 +246,6 @@ $(document).bind("pageinit", function() {
//initialize events
initSocketevents();
- $('.pane').hide();
- $('.sidebar-nav a').bind('click', function(e) {
- var divid = $(e.target).attr('href').substr(1);
- var uri = $(divid + "table").attr('data');
-
- switchContent(divid, uri);
- });
-
resetSong();
if (location.hash.length < 2) {
@@ -291,7 +256,7 @@ $(document).bind("pageinit", function() {
if (window.navigator.standalone) {
$("#btback").show();
} else {
- $("#btback").hide();
+// $("#btback").hide();
}
// $("#songinfo").resize(resizeSonginfo());
@@ -299,10 +264,10 @@ $(document).bind("pageinit", function() {
window.onhashchange = locationHashChanged;
// Log all events
mopidy.on(function() {
- // console.log(arguments);
+ // console.log(arguments);
});
- //update gui every x seconds from mopdidy
- setInterval(updateStatusOfAll, 5000);
+ //update gui status every x seconds from mopdidy
+ setInterval(updateTimer, STATUS_TIMER);
});
/************************
@@ -317,6 +282,13 @@ function switchContent(divid, uri) {
location.hash = "#" + hash;
}
+//update timer
+function updateStatusOfAll() {
+ mopidy.playback.getCurrentTrack().then(processCurrenttrack, console.error);
+ mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
+//TODO check offline?
+}
+
//update everything as if reloaded
function updateStatusOfAll() {
mopidy.playback.getCurrentTrack().then(processCurrenttrack, console.error);
@@ -327,8 +299,6 @@ function updateStatusOfAll() {
mopidy.playback.getRandom().then(processRandom, console.error);
mopidy.playback.getVolume().then(processVolume, console.error);
-
- //TODO check offline?
}
function locationHashChanged() {
@@ -365,10 +335,9 @@ function locationHashChanged() {
}
break;
}
- showLoading(false);
// Set the page title based on the hash.
- //document.title = PROGRAM_NAME;
+ document.title = PROGRAM_NAME;
$('.pane').hide();
$('#' + divid + 'pane').show();
return false;
- }
\ No newline at end of file
+ }
diff --git a/webclient/js/library.js b/webclient/js/library.js
index 3d2126b..69071fa 100644
--- a/webclient/js/library.js
+++ b/webclient/js/library.js
@@ -40,7 +40,7 @@ function processSearchResults(resultArr) {
$(SEARCH_ARTIST_TABLE).empty();
$(SEARCH_ALBUM_TABLE).empty();
//get the right result
- // 0 = raspberry 1 = dev.
+ // 0 = older raspberry 1 = dev.
// var results = resultArr[0];
var results = resultArr[1];
var tracks = (results.tracks) ? results.tracks : '';