Comparing version 1.1.0 to 2.0.0
34
bin.js
@@ -9,6 +9,6 @@ #!/usr/bin/env node | ||
var mime = require('mime') | ||
var bonjour = require('bonjour')() | ||
var rangeParser = require('range-parser') | ||
var ip = require('internal-ip').v4() | ||
var AirPlay = require('airplay-protocol') | ||
var enableDestroy = require('server-destroy') | ||
var airplayer = require('./')() | ||
@@ -30,11 +30,11 @@ var argv = require('minimist')(process.argv.slice(2)) | ||
var browser = bonjour.find({ type: 'airplay' }, onTv) | ||
airplayer.on('update', onTv) | ||
function onTv (tv) { | ||
if (interactive) tvs.add(tv) | ||
else play(tv) | ||
function onTv (player) { | ||
if (interactive) tvs.add(player) | ||
else play(player) | ||
} | ||
function play (tv) { | ||
browser.stop() | ||
function play (player) { | ||
airplayer.destroy() | ||
@@ -61,20 +61,12 @@ var server = http.createServer(function (req, res) { | ||
var airplay = AirPlay(tv.host, tv.port) | ||
airplay.on('state', function (state) { | ||
console.log('new state:', state) | ||
player.on('event', function (event) { | ||
if (event.state === 'stopped') server.destroy() | ||
}) | ||
airplay._rserver.on('error', function (err) { | ||
throw err | ||
}) | ||
airplay._rserver.on('end', function () { | ||
console.log('end event') | ||
}) | ||
airplay._rserver.on('close', function () { | ||
console.log('close event') | ||
}) | ||
airplay.play('http://' + ip + ':' + port + '/stream.m4v', function (err, res, body) { | ||
player.play('http://' + ip + ':' + port + '/stream.m4v', function (err, res, body) { | ||
if (err) throw err | ||
}) | ||
}) | ||
enableDestroy(server) | ||
} | ||
@@ -81,0 +73,0 @@ |
13
index.js
@@ -8,3 +8,3 @@ 'use strict' | ||
module.exports = function () { | ||
var bonjour = Bonjour() | ||
var bonjour = new Bonjour() | ||
var list = new EventEmitter() | ||
@@ -14,9 +14,11 @@ var found = [] | ||
if (~found.indexOf(service.fqdn)) return | ||
found.push(service.fqdn) | ||
var player = new AirPlay(service.host, service.port) | ||
player.name = service.name | ||
player.on('event', function (event) { | ||
if (event.state === 'stopped') list.destroy() | ||
}) | ||
found.push(service.fqdn) | ||
list.players.push(player) | ||
list.emit('update', player) | ||
@@ -27,8 +29,5 @@ }) | ||
list.update = browser.update.bind(browser) | ||
list.destroy = function () { | ||
browser.stop() | ||
bonjour.destroy() | ||
} | ||
list.destroy = bonjour.destroy.bind(bonjour) | ||
return list | ||
} |
{ | ||
"name": "airplayer", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "Query your local network for Apple TV's and have them play videos", | ||
@@ -8,9 +8,10 @@ "main": "index.js", | ||
"dependencies": { | ||
"airplay-protocol": "^1.1.0", | ||
"airplay-protocol": "^2.0.2", | ||
"appendable-cli-menu": "^2.0.0", | ||
"bonjour": "^3.3.0", | ||
"bonjour": "^3.3.1", | ||
"internal-ip": "^1.2.0", | ||
"mime": "^1.3.4", | ||
"minimist": "^1.2.0", | ||
"range-parser": "^1.0.3" | ||
"range-parser": "^1.0.3", | ||
"server-destroy": "^1.0.1" | ||
}, | ||
@@ -39,2 +40,5 @@ "devDependencies": { | ||
], | ||
"engines": { | ||
"node": ">= 0.12" | ||
}, | ||
"author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)", | ||
@@ -47,5 +51,5 @@ "license": "MIT", | ||
"coordinates": [ | ||
55.6469012, | ||
12.5508987 | ||
52.5307717, | ||
13.3839318 | ||
] | ||
} |
@@ -57,5 +57,10 @@ # airplayer | ||
Creates a AirPlay list. When creating a new list it will call | ||
`list.update()` once. It is up to you to call afterwards incase you want | ||
to update the list. | ||
`list.update()` once. It is up to you to call afterwards in case you | ||
want to update the list. | ||
### `list.players` | ||
An array of the players that have been found on the local network so | ||
far. | ||
### `list.update()` | ||
@@ -62,0 +67,0 @@ |
Sorry, the diff of this file is not supported yet
7651
87
8
117
+ Addedserver-destroy@^1.0.1
+ Addedairplay-protocol@2.0.2(transitive)
+ Addedserver-destroy@1.0.1(transitive)
- Removedairplay-protocol@1.2.1(transitive)
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updatedairplay-protocol@^2.0.2
Updatedbonjour@^3.3.1