A low level protocol wrapper on top of the AirPlay HTTP API
npm install airplay-protocolA low level protocol wrapper on top of the AirPlay HTTP API used to
connect to an Apple TV.
**For a proper AirPlay client, see
airplayer instead.**
Currently only the video API is implemented.


```
npm install airplay-protocol --save
`js
var AirPlay = require('airplay-protocol')
var airplay = new AirPlay('apple-tv.local')
airplay.play('http://example.com/video.m4v', function (err) {
if (err) throw err
airplay.playbackInfo(function (err, res, body) {
if (err) throw err
console.log('Playback info:', body)
})
})
`
Initiate a connection to a specific AirPlay server given a host or IP
address and a port. If no port is given, the default port 7000 is used.
Returns an instance of the AirPlay object.
`js
var AirPlay = require('airplay-protocol')
var airplay = new AirPlay('192.168.0.42', 7000)
`
`js`
function (event) {}
Emitted every time the AirPlay server sends an event. Events can hold
different types of data, but will among other things be used to send
updates to the playback state.
Example event object indicating the state of the playback have changed:
`js`
{
category: 'video',
params: {
uuid: 'D90C289F-DE6A-480C-A741-1DA92CEEE8C3-40-00000004654E2487'
},
sessionID: 3,
state: 'loading'
}
The event.params property can potentially hold a lot more data than
shown in this example.
Example event object indicating an update to the access log:
`js`
{
params: {
uuid: '96388EC8-05C8-4BC4-A8EB-E9B6FCEB1A55-41-000000135E436A63'
},
sessionID: 0,
type: 'accessLogChanged'
}
Property holding the latest playback state emitted by the event event.undefined
Will be if no event event have been emitted yet.
Possible states: loading, playing, paused or stopped.
Get the AirPlay server info.
Arguments:
- callback - Will be called when the request have been processed byhttp.IncomingMessage
the AirPlay server. The first argument is an optional Error object.
The second argument is an instance of [][1] and
the third argument is a parsed plist object containing the server info
Start video playback.
Arguments:
- url - The URL to playposition
- (optional) - A floating point number between 0 and 10
where represents the begining of the video and 1 the end.0
Defaults to callback
- (optional) - Will be called when the request have beenhttp.IncomingMessage
processed by the AirPlay server. The first argument is an optional
Error object. The second argument is an instance of
[][1]
Retrieve the current playback position.
Arguments:
- callback - Will be called when the request have been processed byhttp.IncomingMessage
the AirPlay server. The first argument is an optional Error object.
The second argument is an instance of [][1] and
the third argument is the current playback position
Seek to an arbitrary location in the video.
Arguments:
- position - A float value representing the location in secondscallback
- (optional) - Will be called when the request have beenhttp.IncomingMessage
processed by the AirPlay server. The first argument is an optional
Error object. The second argument is an instance of
[][1]
Change the playback rate.
Arguments:
- speed - A float value representing the playback rate: 0 is paused, 1callback
is playing at the normal speed
- (optional) - Will be called when the request have beenhttp.IncomingMessage
processed by the AirPlay server. The first argument is an optional
Error object. The second argument is an instance of
[][1]
Pause playback.
Alias for airplay.rate(0, callback).
Resume playback.
Alias for airplay.rate(1, callback).
Stop playback.
Arguments:
- callback (optional) - Will be called when the request have beenhttp.IncomingMessage
processed by the AirPlay server. The first argument is an optional
Error object. The second argument is an instance of
[][1]
Retrieve playback informations such as position, duration, rate,
buffering status and more.
Arguments:
- callback - Will be called when the request have been processed byhttp.IncomingMessage
the AirPlay server. The first argument is an optional Error object.
The second argument is an instance of [][1] and
the third argument is a parsed plist object containing the playback info
Get playback property.
Arguments:
- name - The name of the property to getcallback
- - Will be called when the request have been processed byhttp.IncomingMessage
the AirPlay server. The first argument is an optional Error object.
The second argument is an instance of [][1] and
the third argument is a parsed plist object containing the property
Set playback property.
Arguments:
- name - The name of the property to setvalue
- - The plist object to setcallback
- (optional) - Will be called when the request have beenhttp.IncomingMessage`][1]
processed by the AirPlay server. The first argument is an optional
Error object. The second argument is an instance of
[
Destroy the reverse-http server set up to receive AirPlay events.
MIT
[1]: https://nodejs.org/api/http.html#http_class_http_incomingmessage