<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>MPC-HC WebServer - Variables</title> <link rel="stylesheet" href="default.css"> <link rel="icon" href="favicon.ico"> </head> <body> <!--[if lt IE 8]> <div class="browser-warning"><strong>Warning!</strong> You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</div> <![endif]--> <p id="filepatharg">D:%5cFILMS%5cIts.Always.Sunny.in.Philadelphia.S10E10.720p.WEB.rus.LostFilm.TV.mp4</p> <p id="filepath">D:\FILMS\Its.Always.Sunny.in.Philadelphia.S10E10.720p.WEB.rus.LostFilm.TV.mp4</p> <p id="filedirarg">D:%5cFILMS</p> <p id="filedir">D:\FILMS</p> <p id="state">1</p> <p id="statestring"></p> <p id="position">1069384</p> <p id="positionstring">00:17:49</p> <p id="duration">1255210</p> <p id="durationstring">00:20:55</p> <p id="volumelevel">75</p> <p id="muted">0</p> <p id="playbackrate">1</p> <p id="reloadtime">0</p> </body> </html>
<p id=""></p>
main.prototype.get = function(){ var that = this return new Promise(function(done){ http.get(that.mpc_uri, function(res) { res.on('data', function (chunk) { that.mpc_obj.parse(chunk) done(that.mpc_obj.get()); }); }).on('error', function(e) { done(e.message); }); }) }
MPC_obj.prototype.parse = function(data){ var obj = {} data.toString().split('\n').forEach(function(line){ // , if (match=/\<p/.test(line)){ var name2 = line.match(/id\=\"(\w+)\"/)[1] if (!obj.hasOwnProperty(name2)) obj[name2]=line.substring(line.indexOf('>')+1,line.lastIndexOf('<')) } }) this.settings=obj; }
{ filepatharg: 'D:%5cmbrr555.avi', filepath: 'D:\\mbrr555.avi', filedirarg: 'D:%5c', filedir: 'D:\\', state: '1', statestring: '', position: '1023', positionstring: '00:00:01', duration: '114906', durationstring: '00:01:54', volumelevel: '77', muted: '0', playbackrate: '1', reloadtime: '0' }
// MPC_obj.prototype.getProgress = function(){ return (this.settings["position"]/this.settings["duration"]).toFixed(5) } // (PWM) 1,0 -> 255 MPC_obj.prototype.PWM = function(){ return (this.getProgress()*255).toFixed(0) }
var SerialPort = require('serialport').SerialPort; var serialPort = new SerialPort("COM5", { baudrate: 57600 }, false);
serialPort.open(function (error) { if ( error ) { console.log('failed to open: '+error); } else { console.log('open'); // arduino serialPort.on('data', function(data) { main.init(function(a){ // serialPort.write(a); }); }); } });
int inByte = 0; void setup() { pinMode(9, OUTPUT); pinMode(3, OUTPUT); analogWrite(3, 0); analogWrite(9, 0); Serial.begin(57600); } void loop() { Serial.print('A'); delay(100); if (Serial.available() > 0) { analogWrite(3, 5); inByte = Serial.parseInt(); analogWrite(9, inByte); if (inByte==255) analogWrite(3, 255); } }
Source: https://habr.com/ru/post/254911/
All Articles