|
|
|
|
@ -31,7 +31,17 @@ server.get(/\/client\/?.*/, restify.serveStatic({
|
|
|
|
|
// Cödê
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global.mpvdata = [];
|
|
|
|
|
global.mpvstate = {
|
|
|
|
|
"percent-pos":null,
|
|
|
|
|
"time-pos":null,
|
|
|
|
|
"time-remaining":null,
|
|
|
|
|
"chapter":null,
|
|
|
|
|
"chapter-list/count":null,
|
|
|
|
|
"pause":null,
|
|
|
|
|
"volume":null,
|
|
|
|
|
"mute":null,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
global.mpvsocket = null;
|
|
|
|
|
global.mpvisConnected = false;
|
|
|
|
|
global.mpvconnect = function() {
|
|
|
|
|
@ -97,6 +107,18 @@ function writeCommand(cmd, params) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function stateUpdate() {
|
|
|
|
|
log.info("updating state");
|
|
|
|
|
for(var key in global.mpvstate) {
|
|
|
|
|
global.mpvconnect().then(function(sock){
|
|
|
|
|
|
|
|
|
|
}, function(reason){
|
|
|
|
|
log.error("could not update state because "+reason);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// /seekTime/:time — seeks relative
|
|
|
|
|
// /seekPercent/:percent — seeks percent absolute
|
|
|
|
|
// /seekChapter/:where — seeks to prev (where=-x) or next (where=+x) chapter
|
|
|
|
|
@ -104,6 +126,8 @@ function writeCommand(cmd, params) {
|
|
|
|
|
// /progress — show osd progress
|
|
|
|
|
// /playpause — toggles playing
|
|
|
|
|
// /muteunmute — toggles muting
|
|
|
|
|
// /stateUpdate — update state
|
|
|
|
|
// /stateVar/:name — get value of tracked property with name
|
|
|
|
|
|
|
|
|
|
server.get('/seek/:time', function (req, res, next) {
|
|
|
|
|
log.info("seek "+req.params.time);
|
|
|
|
|
@ -187,6 +211,11 @@ server.get('/muteunmute', function (req, res, next) {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
server.get('/stateUpdate', function (req, res, next) {
|
|
|
|
|
log.info("stateUpdate ");
|
|
|
|
|
stateUpdate();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
server.listen(8080, function() {
|
|
|
|
|
console.log('%s listening at %s', server.name, server.url);
|
|
|
|
|
});
|
|
|
|
|
|