fixed browsing bug, timer bug

This commit is contained in:
woutervanwijk 2014-03-07 13:44:07 +01:00
parent 837c7ba4ee
commit e40032d17c
5 changed files with 25 additions and 21 deletions

View File

@ -11,6 +11,7 @@ function playBrowsedTracks(addtoqueue, trackid) {
var selected = 0, counter = 0;
//only add one station for dirble, otherwise add all tracks
if (isRadioUri(trackid)) {
alert(trackid);
mopidy.tracklist.add(null, null, trackid);
} else {
//add all items in the playlist
@ -391,7 +392,7 @@ function doSeekPos(value) {
var val = $("#trackslider").val();
newposition = Math.round(val);
if (!initgui) {
pauseTimer();
pausePosTimer();
//set timer to not trigger it too much
clearTimeout(seekTimer);
$("#songelapsed").html(timeFromSeconds(val / 1000));
@ -406,7 +407,7 @@ function triggerPos() {
// console.log(newposition);
mopidy.playback.seek(newposition);
// mopidy.playback.resume();
resumeTimer();
resumePosTimer();
posChanging = false;
}
}
@ -418,7 +419,7 @@ function setPosition(pos) {
var oldval = initgui;
if (pos > songlength) {
pos = songlength;
pauseTimer();
pausePosTimer();
}
currentposition = pos;
initgui = true;
@ -467,30 +468,30 @@ function doMute() {
}
/*******
* Track timer
* Track position timer
*/
//timer function to update interface
function updateTimer() {
function updatePosTimer() {
currentposition += TRACK_TIMER;
setPosition(currentposition);
// $("#songelapsed").html(timeFromSeconds(currentposition / 1000));
}
function resumeTimer() {
pauseTimer();
function resumePosTimer() {
pausePosTimer();
if (songlength > 0) {
posTimer = setInterval(updateTimer, TRACK_TIMER);
posTimer = setInterval(updatePosTimer, TRACK_TIMER);
}
}
function initTimer() {
pauseTimer();
function initPosTimer() {
pausePosTimer();
// setPosition(0);
resumeTimer();
resumePosTimer();
}
function pauseTimer() {
function pausePosTimer() {
clearInterval(posTimer);
}

View File

@ -429,5 +429,5 @@ $.event.special.swipe = $.extend($.event.special.swipe, {
function isRadioUri (uri) {
var uriSplit = uri.split(":");
return validUri || radioExtensionsUris.indexOf(uriSplit[0].toLowerCase()) >= 0;
return validUri(uri) || radioExtensionsUris.indexOf(uriSplit[0].toLowerCase()) >= 0;
}

View File

@ -8,7 +8,7 @@
********************/
function resetSong() {
if (!posChanging) {
pauseTimer();
pausePosTimer();
setPlayState(false);
setPosition(0);
@ -79,6 +79,7 @@ function resizeMb() {
function setSongInfo(data) {
if (!data || (songdata == data) ) { return; }
if (data.name == '') {
// data.name = data.uri;
return;
};
@ -138,7 +139,7 @@ function setSongInfo(data) {
if (!data.length || data.length == 0) {
songlength = 0;
$("#songlength").html('');
pauseTimer();
pausePosTimer();
$('#trackslider').slider('disable');
$('#radionameinput').val(data.name);
$('#radiouriinput').val(data.uri);
@ -260,12 +261,12 @@ function initSocketevents() {
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
setPlayState(true);
setSongInfo(data.tl_track.track);
initTimer();
initPosTimer();
});
mopidy.on("event:trackPlaybackPaused", function(data) {
//setSongInfo(data.tl_track.track);
pauseTimer();
pausePosTimer();
setPlayState(false);
});
@ -287,7 +288,7 @@ function initSocketevents() {
break;
case "playing":
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
resumeTimer();
resumePosTimer();
setPlayState(true);
break;
}
@ -368,7 +369,7 @@ function setHeadline(site){
}
//update timer
function updateTimer() {
function updateStatusTimer() {
mopidy.playback.getCurrentTrack().then(processCurrenttrack, console.error);
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
//TODO check offline?
@ -498,7 +499,8 @@ $(document).ready(function(event) {
window.onhashchange = locationHashChanged;
//update gui status every x seconds from mopdidy
setInterval(updateTimer, STATUS_TIMER);
setInterval(updateStatusTimer, STATUS_TIMER);
//only show backbutton if in UIWebview
if (window.navigator.standalone) {
$("#btback").show();

0
webclient/js/jquery.mobile-1.3.2.min.js vendored Normal file → Executable file
View File

View File

@ -9,6 +9,7 @@
* process results of a (new) currently playing track
*********************************************************/
function processCurrenttrack(data) {
// console.log(data);
setSongInfo(data);
}
@ -49,7 +50,7 @@ function processCurrentposition(data) {
function processPlaystate(data) {
if (data == 'playing') {
setPlayState(true);
resumeTimer();
resumePosTimer();
} else {
setPlayState(false);
}