fixed browsing bug, timer bug
This commit is contained in:
parent
837c7ba4ee
commit
e40032d17c
25
webclient/js/controls.js
vendored
25
webclient/js/controls.js
vendored
@ -11,6 +11,7 @@ function playBrowsedTracks(addtoqueue, trackid) {
|
|||||||
var selected = 0, counter = 0;
|
var selected = 0, counter = 0;
|
||||||
//only add one station for dirble, otherwise add all tracks
|
//only add one station for dirble, otherwise add all tracks
|
||||||
if (isRadioUri(trackid)) {
|
if (isRadioUri(trackid)) {
|
||||||
|
alert(trackid);
|
||||||
mopidy.tracklist.add(null, null, trackid);
|
mopidy.tracklist.add(null, null, trackid);
|
||||||
} else {
|
} else {
|
||||||
//add all items in the playlist
|
//add all items in the playlist
|
||||||
@ -391,7 +392,7 @@ function doSeekPos(value) {
|
|||||||
var val = $("#trackslider").val();
|
var val = $("#trackslider").val();
|
||||||
newposition = Math.round(val);
|
newposition = Math.round(val);
|
||||||
if (!initgui) {
|
if (!initgui) {
|
||||||
pauseTimer();
|
pausePosTimer();
|
||||||
//set timer to not trigger it too much
|
//set timer to not trigger it too much
|
||||||
clearTimeout(seekTimer);
|
clearTimeout(seekTimer);
|
||||||
$("#songelapsed").html(timeFromSeconds(val / 1000));
|
$("#songelapsed").html(timeFromSeconds(val / 1000));
|
||||||
@ -406,7 +407,7 @@ function triggerPos() {
|
|||||||
// console.log(newposition);
|
// console.log(newposition);
|
||||||
mopidy.playback.seek(newposition);
|
mopidy.playback.seek(newposition);
|
||||||
// mopidy.playback.resume();
|
// mopidy.playback.resume();
|
||||||
resumeTimer();
|
resumePosTimer();
|
||||||
posChanging = false;
|
posChanging = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,7 +419,7 @@ function setPosition(pos) {
|
|||||||
var oldval = initgui;
|
var oldval = initgui;
|
||||||
if (pos > songlength) {
|
if (pos > songlength) {
|
||||||
pos = songlength;
|
pos = songlength;
|
||||||
pauseTimer();
|
pausePosTimer();
|
||||||
}
|
}
|
||||||
currentposition = pos;
|
currentposition = pos;
|
||||||
initgui = true;
|
initgui = true;
|
||||||
@ -467,30 +468,30 @@ function doMute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*******
|
/*******
|
||||||
* Track timer
|
* Track position timer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//timer function to update interface
|
//timer function to update interface
|
||||||
function updateTimer() {
|
function updatePosTimer() {
|
||||||
currentposition += TRACK_TIMER;
|
currentposition += TRACK_TIMER;
|
||||||
setPosition(currentposition);
|
setPosition(currentposition);
|
||||||
// $("#songelapsed").html(timeFromSeconds(currentposition / 1000));
|
// $("#songelapsed").html(timeFromSeconds(currentposition / 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
function resumeTimer() {
|
function resumePosTimer() {
|
||||||
pauseTimer();
|
pausePosTimer();
|
||||||
if (songlength > 0) {
|
if (songlength > 0) {
|
||||||
posTimer = setInterval(updateTimer, TRACK_TIMER);
|
posTimer = setInterval(updatePosTimer, TRACK_TIMER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initTimer() {
|
function initPosTimer() {
|
||||||
pauseTimer();
|
pausePosTimer();
|
||||||
// setPosition(0);
|
// setPosition(0);
|
||||||
resumeTimer();
|
resumePosTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function pauseTimer() {
|
function pausePosTimer() {
|
||||||
clearInterval(posTimer);
|
clearInterval(posTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -429,5 +429,5 @@ $.event.special.swipe = $.extend($.event.special.swipe, {
|
|||||||
|
|
||||||
function isRadioUri (uri) {
|
function isRadioUri (uri) {
|
||||||
var uriSplit = uri.split(":");
|
var uriSplit = uri.split(":");
|
||||||
return validUri || radioExtensionsUris.indexOf(uriSplit[0].toLowerCase()) >= 0;
|
return validUri(uri) || radioExtensionsUris.indexOf(uriSplit[0].toLowerCase()) >= 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
********************/
|
********************/
|
||||||
function resetSong() {
|
function resetSong() {
|
||||||
if (!posChanging) {
|
if (!posChanging) {
|
||||||
pauseTimer();
|
pausePosTimer();
|
||||||
|
|
||||||
setPlayState(false);
|
setPlayState(false);
|
||||||
setPosition(0);
|
setPosition(0);
|
||||||
@ -79,6 +79,7 @@ function resizeMb() {
|
|||||||
function setSongInfo(data) {
|
function setSongInfo(data) {
|
||||||
if (!data || (songdata == data) ) { return; }
|
if (!data || (songdata == data) ) { return; }
|
||||||
if (data.name == '') {
|
if (data.name == '') {
|
||||||
|
// data.name = data.uri;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ function setSongInfo(data) {
|
|||||||
if (!data.length || data.length == 0) {
|
if (!data.length || data.length == 0) {
|
||||||
songlength = 0;
|
songlength = 0;
|
||||||
$("#songlength").html('');
|
$("#songlength").html('');
|
||||||
pauseTimer();
|
pausePosTimer();
|
||||||
$('#trackslider').slider('disable');
|
$('#trackslider').slider('disable');
|
||||||
$('#radionameinput').val(data.name);
|
$('#radionameinput').val(data.name);
|
||||||
$('#radiouriinput').val(data.uri);
|
$('#radiouriinput').val(data.uri);
|
||||||
@ -260,12 +261,12 @@ function initSocketevents() {
|
|||||||
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
||||||
setPlayState(true);
|
setPlayState(true);
|
||||||
setSongInfo(data.tl_track.track);
|
setSongInfo(data.tl_track.track);
|
||||||
initTimer();
|
initPosTimer();
|
||||||
});
|
});
|
||||||
|
|
||||||
mopidy.on("event:trackPlaybackPaused", function(data) {
|
mopidy.on("event:trackPlaybackPaused", function(data) {
|
||||||
//setSongInfo(data.tl_track.track);
|
//setSongInfo(data.tl_track.track);
|
||||||
pauseTimer();
|
pausePosTimer();
|
||||||
setPlayState(false);
|
setPlayState(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -287,7 +288,7 @@ function initSocketevents() {
|
|||||||
break;
|
break;
|
||||||
case "playing":
|
case "playing":
|
||||||
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
||||||
resumeTimer();
|
resumePosTimer();
|
||||||
setPlayState(true);
|
setPlayState(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -368,7 +369,7 @@ function setHeadline(site){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//update timer
|
//update timer
|
||||||
function updateTimer() {
|
function updateStatusTimer() {
|
||||||
mopidy.playback.getCurrentTrack().then(processCurrenttrack, console.error);
|
mopidy.playback.getCurrentTrack().then(processCurrenttrack, console.error);
|
||||||
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
mopidy.playback.getTimePosition().then(processCurrentposition, console.error);
|
||||||
//TODO check offline?
|
//TODO check offline?
|
||||||
@ -498,7 +499,8 @@ $(document).ready(function(event) {
|
|||||||
window.onhashchange = locationHashChanged;
|
window.onhashchange = locationHashChanged;
|
||||||
|
|
||||||
//update gui status every x seconds from mopdidy
|
//update gui status every x seconds from mopdidy
|
||||||
setInterval(updateTimer, STATUS_TIMER);
|
setInterval(updateStatusTimer, STATUS_TIMER);
|
||||||
|
|
||||||
//only show backbutton if in UIWebview
|
//only show backbutton if in UIWebview
|
||||||
if (window.navigator.standalone) {
|
if (window.navigator.standalone) {
|
||||||
$("#btback").show();
|
$("#btback").show();
|
||||||
|
|||||||
0
webclient/js/jquery.mobile-1.3.2.min.js
vendored
Normal file → Executable file
0
webclient/js/jquery.mobile-1.3.2.min.js
vendored
Normal file → Executable file
@ -9,6 +9,7 @@
|
|||||||
* process results of a (new) currently playing track
|
* process results of a (new) currently playing track
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
function processCurrenttrack(data) {
|
function processCurrenttrack(data) {
|
||||||
|
// console.log(data);
|
||||||
setSongInfo(data);
|
setSongInfo(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ function processCurrentposition(data) {
|
|||||||
function processPlaystate(data) {
|
function processPlaystate(data) {
|
||||||
if (data == 'playing') {
|
if (data == 'playing') {
|
||||||
setPlayState(true);
|
setPlayState(true);
|
||||||
resumeTimer();
|
resumePosTimer();
|
||||||
} else {
|
} else {
|
||||||
setPlayState(false);
|
setPlayState(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user