Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-07-20 14:29:27 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-07-20 14:29:27 +0400
commit7a2ab840a54a6e327988be41852756ddf152baea (patch)
treea2e9fa7ceca93d33a1350a6bcf56a8c131cfc34c /bin
parent263ef5b2596a578c1ff850152b113d40317188e0 (diff)
make airplay2 an optional dependency
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cmd.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/bin/cmd.js b/bin/cmd.js
index b7d1f34..0fd7115 100755
--- a/bin/cmd.js
+++ b/bin/cmd.js
@@ -1,6 +1,5 @@
#!/usr/bin/env node
var address = require('network-address')
-var airplay = require('airplay2')
var chalk = require('chalk')
var clivas = require('clivas')
var cp = require('child_process')
@@ -12,6 +11,11 @@ var numeral = require('numeral')
var path = require('path')
var WebTorrent = require('../')
+// optional dependency
+try {
+ var airplay2 = require('airplay2')
+} catch (err) {}
+
function usage (noLogo) {
if (!noLogo) {
var logo = fs.readFileSync(path.join(__dirname, 'ascii-logo.txt'), 'utf8')
@@ -240,7 +244,11 @@ function onTorrent (torrent) {
if (argv.omx) cp.exec(OMX_EXEC + ' ' + href)
if (argv.mplayer) cp.exec(MPLAYER_EXEC + ' ' + href)
if (argv.airplay) {
- var browser = airplay.createBrowser()
+ if (!airplay2) {
+ console.error('No AirPlay support on this platform')
+ process.exit(1)
+ }
+ var browser = airplay2.createBrowser()
browser.on('deviceOn', function (device) {
device.play(href, 0, function () {})
})