Skip to content

Commit

Permalink
Update Airplay module Switch to Airplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
team-pct committed Oct 27, 2016
1 parent 8701ed6 commit 3a5c44b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"popcorn-txt-api": "git+https://github.com/hackhackhack/popcorn-txt-api",
"adm-zip": "0.4.7",
"dlnacasts": "0.1.0",
"airplay-js": "git+https://github.com/guerrerocarlos/node-airplay-js.git",
"airplayer": "2.0.0",
"async": "2.1.2",
"gitlab": "1.4.1",
"defer-request": "0.0.2",
Expand Down
29 changes: 14 additions & 15 deletions src/app/lib/device/airplay.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(function (App) {
'use strict';

var browser = require('airplay-js').createBrowser(),
var airplayer = require('airplayer'),
list = airplayer(),
collection = App.Device.Collection;

var makeID = function (baseID) {
Expand All @@ -18,36 +19,34 @@
this.device = attrs.device;
this.attributes.id = this.makeID(this.device.serverInfo.macAddress || this.device.serverInfo.deviceId || '' + this.device.id);
this.attributes.name = this.device.name || this.device.serverInfo.model;
this.attributes.address = this.device.info[0];
this.attributes.address = this.device.host;
},
play: function (streamModel) {
var url = streamModel.attributes.src;
this.device.play(url);
},
stop: function () {
this.device.stop(function () {});
this.device.destroy();
},
pause: function () {
this.device.pause();
},
unpause: function () {
this.device.resume();
}
});


browser.on('deviceOn', function (device) {

list.on('update', function (player) {
win.info('Found Apple TV Device Device: %s at %s', player.name, player.host);
player.host = "172.20.10.14";
collection.add(new Airplay({
device: device
device: player
}));
});

browser.on('deviceOff', function (device) {

var model = collection.get({
id: makeID(device.id)
});
if (model) {
model.destroy();
}
});
win.info('Scanning: Local Network for Airplay devices');
browser.start();
App.Device.Airplay = Airplay;

})(window.App);

0 comments on commit 3a5c44b

Please sign in to comment.