Skip to content
Extraits de code Groupes Projets

PlaylistSystem

Ouvert Deurstann a demandé de fusionner dev-deurstann-2 vers master
5 files
+ 114
13
Comparer les modifications
  • Côte à côte
  • En ligne

Fichiers

+ 48
3
@@ -109,6 +109,31 @@ class LktClient {
return __getResult(client);
}
static commandPlaylistList() {
var client = new this();
var once = false;
var result = {};
var dataObj;
function __getResult(client) {
return new Promise(resolv => {
client.m_socket.setTimeout(0);
client.m_socket.on('data', data => {
if (!once) {
client.m_socket.write('listplaylists\n');
once = true;
return null;
} else {
client.close();
dataObj = __mpdToObject(data);
result = dataObj.name.split(" ");
resolv(result);
}
});
});
}
return __getResult(client);
}
/* Arguments:
* - command: The command to execute
* Result:
@@ -141,9 +166,14 @@ class LktClient {
function __getResult(client) {
return new Promise((resolve, reject) => {
client.m_socket.on('data', data => {
if (String(data).includes('playlist')) {
if (String(data).includes(' playlist')) {
logger.info("queue","cc");
LktClient.setQueueUpdated(true);
}
if(String(data).includes(' stored_playlist')) {
logger.info("playlist", "cc2");
LktClient.setPlaylistsUpdated(true);
}
client.m_socket.write(`idle\n`);
return null;
});
@@ -229,7 +259,7 @@ class LktClient {
static commandQueueDelId(id) {
return LktClient.__execSimple(`deleteid ${id}`);
}
static errorStatus(error) {
logger.error('Unable to access lektor status:' + error);
}
@@ -244,6 +274,16 @@ class LktClient {
return this.queue_updated;
}
static playlists_updated = false;
static setPlaylistsUpdated(state) {
this.playlists_updated = state;
}
static isPlaulistsUpdated() {
return this.playlists_updated;
}
static timeData = { elapsed: 0, total: 100, state: 'stop', song: 0 };
static setPlayState(state) {
@@ -268,7 +308,12 @@ function __mpdToObject(string) {
string.split('\n').forEach(line => {
if (line.length <= 1) return;
var couple = line.split(/: (.+)/).slice(0, 2);
ret[couple[0]] = couple[1];
if(!ret[couple[0]]) {
ret[couple[0]] = couple[1];
}
else {
ret[couple[0]] += " " + couple[1];
}
});
return ret;
}
Chargement en cours