npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

airplay-protocol

v2.0.2

Published

A low level protocol wrapper on top of the AirPlay HTTP API

Readme

airplay-protocol

A 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.

Build status js-standard-style

Installation

npm install airplay-protocol --save

Example Usage

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)
  })
})

API

new AirPlay(host[, port])

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.

var AirPlay = require('airplay-protocol')

var airplay = new AirPlay('192.168.0.42', 7000)

Event: event

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:

{
  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:

{
  params: {
    uuid: '96388EC8-05C8-4BC4-A8EB-E9B6FCEB1A55-41-000000135E436A63'
  },
  sessionID: 0,
  type: 'accessLogChanged'
}

airplay.state

Property holding the latest playback state emitted by the event event. Will be undefined if no event event have been emitted yet.

Possible states: loading, playing, paused or stopped.

airplay.serverInfo(callback)

Get the AirPlay server info.

Arguments:

  • callback - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage and the third argument is a parsed plist object containing the server info

airplay.play(url[, position][, callback])

Start video playback.

Arguments:

  • url - The URL to play
  • position (optional) - A floating point number between 0 and 1 where 0 represents the begining of the video and 1 the end. Defaults to 0
  • callback (optional) - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage

airplay.scrub(callback)

Retrieve the current playback position.

Arguments:

  • callback - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage and the third argument is the current playback position

airplay.scrub(position[, callback])

Seek to an arbitrary location in the video.

Arguments:

  • position - A float value representing the location in seconds
  • callback (optional) - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage

airplay.rate(speed[, callback])

Change the playback rate.

Arguments:

  • speed - A float value representing the playback rate: 0 is paused, 1 is playing at the normal speed
  • callback (optional) - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage

airplay.pause([callback])

Pause playback.

Alias for airplay.rate(0, callback).

airplay.resume([callback])

Resume playback.

Alias for airplay.rate(1, callback).

airplay.stop([callback])

Stop playback.

Arguments:

  • callback (optional) - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage

airplay.playbackInfo(callback)

Retrieve playback informations such as position, duration, rate, buffering status and more.

Arguments:

  • callback - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage and the third argument is a parsed plist object containing the playback info

airplay.property(name, callback)

Get playback property.

Arguments:

  • name - The name of the property to get
  • callback - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage and the third argument is a parsed plist object containing the property

airplay.property(name, value[, callback])

Set playback property.

Arguments:

  • name - The name of the property to set
  • value - The plist object to set
  • callback (optional) - Will be called when the request have been processed by the AirPlay server. The first argument is an optional Error object. The second argument is an instance of http.IncomingMessage

airplay.destroy()

Destroy the reverse-http server set up to receive AirPlay events.

License

MIT