You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
987 B
JavaScript

const tasklist = require('tasklist');
const process = require('child_process');
exports.viewVideo = async (req, res, next) => {
// const { VSPlayerPath, videoPath } = req.query;
const { openCmd } = req.query;
let VSPlayerList = await tasklist({
filter:[
`Imagename eq ${global.default_config.VSPlayer}`
],
verbose: true,
});
// 关闭之前打开的所有视频
let closeCmd = '';
for(let task of VSPlayerList) {
closeCmd += `/pid ${task.pid} `;
}
closeCmd = `taskkill ${closeCmd} -t -f`;
if(VSPlayerList.length) {
await process.execSync(closeCmd);
}
// 打开视频
console.log(openCmd);
process.exec(openCmd, function(error, stdout, stderr) {
console.log("error:"+error);
console.log("stdout:"+stdout);
console.log("stderr:"+stderr);
});
res.json({
code: 200,
msg: '启动成功'
});
res.end();
// res.json({})
}