Skip to content

Commit

Permalink
Start of playout commands
Browse files Browse the repository at this point in the history
includes `loadBg`, `load` and `play`

related to #1
  • Loading branch information
respectTheCode committed Sep 19, 2012
1 parent 0d5de2e commit 395c024
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -21,3 +21,5 @@ util.inherits(ccg, events.EventEmitter);
require("./lib/connection")(ccg);
// query commands
require("./lib/query")(ccg);
// query commands
require("./lib/playout")(ccg);
56 changes: 56 additions & 0 deletions lib/playout.js
@@ -0,0 +1,56 @@
module.exports = function (ccg) {
var sendPlayoutCommand = function (self, cmd, channel, file, options, cb) {
cmd += " " + channel;
cmd += " " + file.replace("\\", "\\\\");

if (!cb) {
cb = options;
options = {};
}

if (options.loop) cmd += " LOOP";

// this should be validated
if (options.transition) cmd += " " + options.transition;

if (options.seek && parseInt(options.seek, 10) > 0) cmd += " SEEK " + options.seek;

if (options.length && parseInt(options.seek, 10) > 0) cmd += " SEEK " + options.length;

if (options.filter) cmd += " " + options.filter;

if (options.auto) cmd += " AUTO";

self.sendCommand(cmd, function (err, data) {
cb(err, data);
});
};

// ---
// ccg.load
// ---
// Load media file
// [LOAD](http://casparcg.com/wiki/CasparCG_2.0_AMCP_Protocol#LOAD)
ccg.prototype.load = function (channel, file, options, cb) {
sendPlayoutCommand(this, "LOAD", channel, file, options, cb);
};

// ---
// ccg.loadBg
// ---
// Load media file into background
// [LOADBG](http://casparcg.com/wiki/CasparCG_2.0_AMCP_Protocol#LOADBG)
ccg.prototype.loadBg = function (channel, file, options, cb) {
sendPlayoutCommand(this, "LOADBG", channel, file, options, cb);
};

// ---
// ccg.play
// ---
// Play media file
// [PLAY](http://casparcg.com/wiki/CasparCG_2.0_AMCP_Protocol#PLAY)
ccg.prototype.play = function (channel, file, options, cb) {
sendPlayoutCommand(this, "PLAY", channel, file, options, cb);
};

};

0 comments on commit 395c024

Please sign in to comment.