码迷,mamicode.com
首页 > 其他好文 > 详细

temp

时间:2016-12-07 20:11:13      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:const   exe   nes   lines   out   exec   file   err   bsp   

const fs = require(‘fs‘);
fs.readFile("./mp3.lrc", ‘utf-8‘, (err, data) => {
var lines = data.split(‘\n‘);
//[00:01.00] dfgdfgfdfgfgdfgd
for (var key in lines) {
var matchArray = /\[(\d{2}):(\d{2}).(\d{2})\] (.*)/g.exec(lines[key]);
if (matchArray && matchArray.length == 5) {
var current = matchArray[1] * 60 * 1000 + matchArray[2] * 1000 + parseInt(matchArray[3]);
setTimeout(function () {
console.log(matchArray[4]);
}, current);
} else {
console.log(lines[key]);
}
}

});

 

 

 

const fs = require(‘fs‘);
fs.readFile("./mp3.lrc", ‘utf-8‘, (err, data) => {
var lines = data.split(‘\n‘);
//[00:01.00] dfgdfgfdfgfgdfgd
lines.forEach(function (value, index) {
var matchArray = /\[(\d{2}):(\d{2}).(\d{2})\] (.*)/g.exec(value);
if (matchArray && matchArray.length == 5) {
var current = matchArray[1] * 60 * 1000 + matchArray[2] * 1000 + parseInt(matchArray[3]);
setTimeout(function () {
console.log(matchArray[4]);
}, current);
} else {
console.log(value);
}
});
});

temp

标签:const   exe   nes   lines   out   exec   file   err   bsp   

原文地址:http://www.cnblogs.com/zhaoyihao/p/6141747.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!