castv2-client
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -119,2 +119,111 @@ var util = require('util'); | ||
//Load a queue of items to play (playlist) | ||
//See https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.QueueLoadRequest | ||
MediaController.prototype.queueLoad = function(items, options, callback) { | ||
if(typeof options === 'function' || typeof options === 'undefined') { | ||
callback = options; | ||
options = {}; | ||
} | ||
var data = { type: 'QUEUE_LOAD' }; | ||
//REPEAT_OFF, REPEAT_ALL, REPEAT_SINGLE, REPEAT_ALL_AND_SHUFFLE | ||
data.repeatMode = (typeof options.repeatMode === "string" && | ||
typeof options.repeatMode !== 'undefined') | ||
? options.repeatMode | ||
: "REPEAT_OFF"; | ||
data.currentTime = (typeof options.currentTime !== 'undefined') | ||
? options.currentTime | ||
: 0; | ||
data.startIndex = (typeof options.startIndex !== 'undefined') | ||
? options.startIndex | ||
: 0; | ||
data.items = items; | ||
this.request(data, function(err, response) { | ||
if(err) return callback(err); | ||
if(response.type === 'LOAD_FAILED') { | ||
return callback(new Error('queueLoad failed')); | ||
} | ||
if(response.type === 'LOAD_CANCELLED') { | ||
return callback(new Error('queueLoad cancelled')); | ||
} | ||
var status = response.status[0]; | ||
callback(null, status); | ||
}); | ||
}; | ||
MediaController.prototype.queueInsert = function(items, options, callback) { | ||
if(typeof options === 'function' || typeof options === 'undefined') { | ||
callback = options; | ||
options = {}; | ||
} | ||
var data = { | ||
type: 'QUEUE_INSERT', | ||
currentItemId: options.currentItemId, //Item ID to play after this request or keep same item if undefined | ||
currentItemIndex: options.currentItemIndex, //Item Index to play after this request or keep same item if undefined | ||
currentTime: options.currentTime, //Seek in seconds for current stream | ||
insertBefore: options.insertBefore, //ID or append if undefined | ||
items: items | ||
}; | ||
this.sessionRequest(data, callback); | ||
}; | ||
MediaController.prototype.queueRemove = function(itemIds, options, callback) { | ||
if(typeof options === 'function' || typeof options === 'undefined') { | ||
callback = options; | ||
options = {}; | ||
} | ||
var data = { | ||
type: 'QUEUE_REMOVE', | ||
currentItemId: options.currentItemId, | ||
currentTime: options.currentTime, | ||
itemIds: itemIds | ||
}; | ||
this.sessionRequest(data, callback); | ||
}; | ||
MediaController.prototype.queueReorder = function(itemIds, options, callback) { | ||
if(typeof options === 'function' || typeof options === 'undefined') { | ||
callback = options; | ||
options = {}; | ||
} | ||
var data = { | ||
type: 'QUEUE_REORDER', | ||
currentItemId: options.currentItemId, | ||
currentTime: options.currentTime, | ||
insertBefore: options.insertBefore, | ||
itemIds: itemIds | ||
}; | ||
this.sessionRequest(data, callback); | ||
}; | ||
MediaController.prototype.queueUpdate = function(items, options, callback) { | ||
if(typeof options === 'function' || typeof options === 'undefined') { | ||
callback = options; | ||
options = {}; | ||
} | ||
var data = { | ||
type: 'QUEUE_UPDATE', | ||
currentItemId: options.currentItemId, | ||
currentTime: options.currentTime, | ||
jump: options.jump, //Skip or go back (if negative) number of items | ||
repeatMode: options.repeatMode, | ||
items: items | ||
}; | ||
this.sessionRequest(data, callback); | ||
}; | ||
module.exports = MediaController; |
@@ -49,2 +49,22 @@ var util = require('util'); | ||
module.exports = DefaultMediaReceiver; | ||
DefaultMediaReceiver.prototype.queueLoad = function(items, options, callback) { | ||
this.media.queueLoad.apply(this.media, arguments); | ||
}; | ||
DefaultMediaReceiver.prototype.queueInsert = function(items, options, callback) { | ||
this.media.queueInsert.apply(this.media, arguments); | ||
}; | ||
DefaultMediaReceiver.prototype.queueRemove = function(itemIds, options, callback) { | ||
this.media.queueRemove.apply(this.media, arguments); | ||
}; | ||
DefaultMediaReceiver.prototype.queueReorder = function(itemIds, options, callback) { | ||
this.media.queueReorder.apply(this.media, arguments); | ||
}; | ||
DefaultMediaReceiver.prototype.queueUpdate = function(items, callback) { | ||
this.media.queueUpdate.apply(this.media, arguments); | ||
}; | ||
module.exports = DefaultMediaReceiver; |
{ | ||
"name": "castv2-client", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "A Chromecast client based on the new (CASTV2) protocol", | ||
@@ -5,0 +5,0 @@ "author": "thibauts", |
@@ -104,1 +104,2 @@ castv2-client | ||
* [xat](https://github.com/xat) (Simon Kusterer) | ||
* [angelnu](https://github.com/angelnu) (Angel Nunez Mencias) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28001
603
105