-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.test.js
30 lines (24 loc) · 843 Bytes
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var fs = require("fs");
var m3u8ToMp4 = require("./index.js");
var converter = new m3u8ToMp4();
var demoUrl = "https://content.jwplatform.com/manifests/yp34SRmf.m3u8";
(async function () {
try {
console.log("Starting test...");
await converter
.setInputFile(demoUrl)
.setOutputFile("dummy.mp4")
.start({
onStart: () => console.log('on start'),
onEnd: () => console.log('on end'),
onError: error => console.error(`on error: ${error.message}`),
onProgress: () => console.log('on progress'),
onStderr: (stderrLine) => console.log(`on stderr: ${stderrLine}`),
onCodecData: () => console.log('on codecdata'),
});
fs.unlinkSync("dummy.mp4");
console.log("Success!");
} catch (error) {
throw new Error("Oops, an error occurred!", error);
}
})();