I made some change to the files to get a full timer while playing and not seconds changing every time we make a request to xbmc.
Unfortunately, git doesn't work on my f****ng Ubuntu (tried everything...) so I will post the changes below and if someone likes them, he can add them to git.
It may not be the best way to do that, I'm not a python/flask programmer so excuse me if it's not perfect
![Smile Smile](https://forum.kodi.tv/images/smilies/smile.png)
But it's a start.
Changes :
In index.js under static/js add to the top (before document.ready ) :
Code:
var h;
var m;
var s;
var t;
function setclock(timer){
var time_elem = timer.split(':');
if(time_elem[2]){
h= parseInt(time_elem[0],10);
m = parseInt(time_elem[1],10);
s = parseInt(time_elem[2],10);
}
else{
h= 0;
m = parseInt(time_elem[0],10);
s = parseInt(time_elem[1],10);
}
maj_time();
}
function maj_time(){
if (s<59){
s++;
} else {
if(m<59){
m++;
}
else {
h++;
m=0;
}
s=0;
}
if(s<10) seconds='0' + s; else seconds=s
if(m<10) minutes='0'+ m;else minutes = m;
if(h<10) hours='0' + h;else hours = h;
if(h!='00'){
new_time = hours + ':' + minutes + ':' + seconds;
} else {
new_time = minutes + ':' + seconds;
}
$(".current").text(new_time);
t=setTimeout("maj_time()",1000);
}
then still in index.js search for play/pause control and modify :
Code:
// play/pause control
$('#currently_playing .controls .play_pause').live('click', function() {
$.get('/xhr/controls/play_pause'[b],function(data){
if(data.success==0) clearTimeout(t);}
);[/b]
});
// stop control
$('#currently_playing .controls .stop').live('click', function() {
$.get('/xhr/controls/stop');
[b]clearTimeout(t);[/b]
});
Now in currently_playing.py around the end request the speed property:
Code:
time = xbmc.Player.GetProperties(playerid=1, properties=['time', 'totaltime', 'position', 'percentage', [b]'speed'[/b]])
return render_template('currently_playing.html',
currently_playing = currently_playing,
fanart = fanart,
time = time,
current_time = format_time(time['time']),
total_time = format_time(time['totaltime']),
percentage_progress = int(time['percentage']),
[b]speed = int(time['speed']),[/b]
)
In control.py at the end modify :
Code:
if command == 'play_pause':
xbmc.Player.PlayPause(playerid=1)
[b]playing = xbmc.Player.GetProperties(playerid=1, properties=['speed'])
running = int(playing['speed'])[/b]
elif command == 'stop':
xbmc.Player.Stop(playerid=1)
return jsonify({ [b]'success': running [/b]})
and finnaly in currently_playing.html under template at line 27 add :
Code:
<script type="text/javascript"> clearTimeout(t);</script>
{% if speed==1 %}<script type="text/javascript">setclock('{{ current_time }}');</script>{% endif %}
That's it! So basicaly I pass the current_time to a javascript which will increment it until we get a new value from xbmc (every 4-5 seconds). It will stop if you press play/pause also (depending if it's a play or a pause^^). And stop if you stop of course
Hope you like it!
Next work : possibility to seek!