-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
51 lines (35 loc) · 1.06 KB
/
index.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var fs = require('fs');
var OMXPlayer = require('./lib/omxplayer');
var commander;
try {
commander = require('commander');
} catch (x) {
console.error("You must install the package 'commander' for this sample ! (npm install commander)");
process.exit(1);
}
commander.version(require("./package.json").version);
OMXPlayer.fillCommanderOptions(commander);
commander.command('*').description("node-omxplayer <filename> [filenames ...]").action(function(fileNames) {
var omxplayer = new OMXPlayer(commander);
var list = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
console.log("Arguments=", list);
function start() {
if (!list.length) {
console.log("Last movie done !");
return;
}
var next = list.shift();
var stream = fs.openSync(next, 'r');
console.log("Start movie", next, " stream=", stream);
omxplayer.stream(stream, function(error) {
fs.close(stream);
if (error) {
console.error("Start error: ", error);
return;
}
omxplayer.once("stopped", start);
});
}
start();
});
commander.parse(process.argv);