我的服务器上有一个.ts文件,我的用户可以使用该文件访问我的实时流。我想知道如何通过Node JS获取流的状态(在线还是离线)?
我在网上到处都看过,但发现的只是如何检查.ts文件是否可用!
提前谢谢!
编辑1:
const parsers = require('playlist-parser');
const M3U = parsers.M3U;
const path = require('path');
const timeout = 5000;
let failures = 0;
const http = axios.create({timeout});
http.defaults.headers.common["User-Agent"] = "VLC/2.2.4 LibVLC/2.2.4";
function writeToLog(test) {
const line = `${test}(): `;
console.log(line);
}
async function testAllLinksIsWorking() {
try {
console.log(await http.get("http://djing.com/tv/animation.m3u8"));
} catch (err) {
failures++;
writeToLog(err);
}
}
console.log('Test is running...');
testAllLinksIsWorking();
这是结果:Result PasteBin