Skip to content
Extraits de code Groupes Projets
Valider 117cd18e rédigé par Deurstann's avatar Deurstann
Parcourir les fichiers

Progress bar does now follow song playtime

parent 5b2c06c3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!6Move application and playtime visualisation
...@@ -161,6 +161,26 @@ class LktClient { ...@@ -161,6 +161,26 @@ class LktClient {
return __getResult(client); return __getResult(client);
} }
static statusActualisation() {
var client = new this();
var dataObj;
function __getResult(client) {
return new Promise(resolv => {
client.m_socket.setTimeout(0);
setInterval(()=>client.m_socket.write(`status\n`),100);
client.m_socket.on('data', data => {
dataObj = __mpdToObject(data);
//logger.info('lkt', `elapsed:${dataObj.elapsed}, total:${dataObj.duration}`);
if(dataObj.elapsed && dataObj.duration && dataObj.state) {
LktClient.setSongTimeData(parseInt(dataObj.elapsed,10), parseInt(dataObj.duration,10), dataObj.state);
}
});
});
}
return __getResult(client);
}
static commandPlay() { static commandPlay() {
var status = LktClient.commandStatus(); var status = LktClient.commandStatus();
return status.then(LktClient.changePlayStatus, LktClient.errorStatus); return status.then(LktClient.changePlayStatus, LktClient.errorStatus);
...@@ -179,8 +199,10 @@ class LktClient { ...@@ -179,8 +199,10 @@ class LktClient {
default: default:
logger.info('Unknown play state' + status.state); logger.info('Unknown play state' + status.state);
} }
LktClient.setPlayState(status.state);
} }
static commandPlayPos(position) { static commandPlayPos(position) {
this.setSongTimeData(0,this.timeData.total,this.timeData.state);
return LktClient.__execSimple(`play ${position}`); return LktClient.__execSimple(`play ${position}`);
} }
static commandStop() { static commandStop() {
...@@ -200,7 +222,6 @@ class LktClient { ...@@ -200,7 +222,6 @@ class LktClient {
return LktClient.__execSimple('clear'); return LktClient.__execSimple('clear');
} }
static commandMove(from, to) { static commandMove(from, to) {
logger.info("lkt", `move ${from} ${to}`)
return LktClient.__execSimple(`move ${from} ${to}`); return LktClient.__execSimple(`move ${from} ${to}`);
} }
...@@ -211,12 +232,12 @@ class LktClient { ...@@ -211,12 +232,12 @@ class LktClient {
return LktClient.__execSimple(`__insert id://${id}`); return LktClient.__execSimple(`__insert id://${id}`);
} }
static commandQueueDelPos(position) { static commandQueueDelPos(position) {
logger.info("lkt", `delete ${position}`)
return LktClient.__execSimple(`delete ${position}`); return LktClient.__execSimple(`delete ${position}`);
} }
static commandQueueDelId(id) { static commandQueueDelId(id) {
return LktClient.__execSimple(`deleteid ${id}`); return LktClient.__execSimple(`deleteid ${id}`);
} }
static errorStatus(error) { static errorStatus(error) {
logger.error('Unable to access lektor status:' + error); logger.error('Unable to access lektor status:' + error);
} }
...@@ -230,6 +251,19 @@ class LktClient { ...@@ -230,6 +251,19 @@ class LktClient {
static isQueueUpdated() { static isQueueUpdated() {
return this.queue_updated; return this.queue_updated;
} }
static timeData = {elapsed:0, total:100, state:'stop'};
static setPlayState(state) {
this.timeData.state = state;
}
static setSongTimeData(elapsed, total, state) {
this.timeData = {elapsed:elapsed, total:total, state:state};
}
static getSongTimeData() {
return this.timeData;
}
} }
function __mpdToObject(string) { function __mpdToObject(string) {
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
></ul> ></ul>
</div> </div>
<div <div
id="progressBar" id="progress"
class="progress" class="progress"
style=" style="
z-index: 666; z-index: 666;
...@@ -54,8 +54,13 @@ ...@@ -54,8 +54,13 @@
> >
<div <div
class="progress-bar" class="progress-bar"
id="progressBar"
role="progressbar" role="progressbar"
style="width: 75%" style="-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;"
></div> ></div>
</div> </div>
</div> </div>
......
...@@ -52,6 +52,7 @@ window.onload = () => { ...@@ -52,6 +52,7 @@ window.onload = () => {
setTimeout(() => ipcRenderer.send('reload-queue-request'), 1000); setTimeout(() => ipcRenderer.send('reload-queue-request'), 1000);
setInterval(() => ipcRenderer.send('verify-queue-reloaded-request'), 50); setInterval(() => ipcRenderer.send('verify-queue-reloaded-request'), 50);
setInterval(() => ipcRenderer.send('get-song-time-data'),50);
logger.debug('instance', 'Window loaded'); logger.debug('instance', 'Window loaded');
$('#filterInput').on('keypress', e => { $('#filterInput').on('keypress', e => {
...@@ -174,10 +175,12 @@ ipcRenderer.on('reload-queue-responce', (event, arg) => { ...@@ -174,10 +175,12 @@ ipcRenderer.on('reload-queue-responce', (event, arg) => {
); );
}); });
/*ipcRenderer.on('queue-moved-responce', (event, arg) => { ipcRenderer.on('send-song-time-data', (event,timeData) => {
logger.info('Time', new Date().getTime() - time);
ipcRenderer.send('reload-queue-request'); document.getElementById('progressBar').style.width=
});*/ `${timeData.elapsed/timeData.total*document.documentElement.clientWidth}px`;
});
function addDBKaraEventHandlers(element) { function addDBKaraEventHandlers(element) {
......
...@@ -146,7 +146,10 @@ app.on('ready', () => { ...@@ -146,7 +146,10 @@ app.on('ready', () => {
}); });
setTimeout(() => { setTimeout(() => {
lkt.idleActualisation(); lkt.idleActualisation();
}, 500); }, 1000);
setTimeout(()=> {
lkt.statusActualisation();
}, 1500);
lektor.on('close', code => { lektor.on('close', code => {
logger.warn('main', `Lektor exited with code ${code}`); logger.warn('main', `Lektor exited with code ${code}`);
lektor_closed = true; lektor_closed = true;
...@@ -234,10 +237,27 @@ ipcMain.on('insert-kara-queue-id', (event, arg) => { ...@@ -234,10 +237,27 @@ ipcMain.on('insert-kara-queue-id', (event, arg) => {
}); });
ipcMain.on('delete-kara-queue-pos', (event, arg) => { ipcMain.on('delete-kara-queue-pos', (event, arg) => {
logger.info("cc");
lkt.commandQueueDelPos(arg.position); lkt.commandQueueDelPos(arg.position);
}); });
ipcMain.on('add-kara-queue-pos', (event,addparams) => { ipcMain.on('add-kara-queue-pos', (event,addparams) => {
lkt.commandQueueAddId(addparams.id).then(() => lkt.commandMove(addparams.queueSize+1,addparams.position)); lkt.commandQueueAddId(addparams.id).then(() => lkt.commandMove(addparams.queueSize+1,addparams.position));
}) });
\ No newline at end of file
var songTimeData = {elapsed:0,total:100,state:'stop'};
var counterTime = 0;
ipcMain.on('get-song-time-data', (event,arg) => {
var newSongTimeData = lkt.getSongTimeData();
if(newSongTimeData.elapsed != songTimeData.elapsed) {
songTimeData = newSongTimeData;
event.reply('send-song-time-data',{elapsed:songTimeData.elapsed, total:songTimeData.total});
counterTime = 0;
}
else if(newSongTimeData.state == 'play') {
counterTime++;
event.reply('send-song-time-data',{elapsed:songTimeData.elapsed+(counterTime/20.0), total:songTimeData.total});
}
else {
event.reply('send-song-time-data',{elapsed:songTimeData.elapsed+(counterTime/20.0), total:songTimeData.total})
}
});
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter