Skip to main content
Version: 11.7.0

AirPlay on iOS

AirPlay is a casting technology developed by Apple. AirPlay allows viewers to mirror their videos between AirPlay-enabled sender and receiver devices.

  • iPhones, iPads and MacBooks are possible AirPlay-enabled sender devices.
  • Apple TVs or AirPlay–enabled smart TVs are possible AirPlay-enabled receiver devices.

THEOplayer offers support for AirPlay on AirPlay-enabled devices through its Web SDK and iOS SDK.

How to enable AirPlay

Ensure that an AirPlay-enabled receiver device is connected to your network, because you might not see an AirPlay icon otherwise. Additionally, note that AirPlay is only supported by Apple on a limited set of devices and browsers. For example, you cannot do AirPlay on a Chrome browser on a macOS device, even though it's an Apple device.

API

As a developer, you might need to use the THEOplayer AirPlay API to build a custom AirPlay UI and UX, or to dispatch an event to an analytics service, or for workflow purposes.

For more information, see the API reference of AirPlay, a sub-protocol of Cast.

Use the API as demonstrated below:

private func setupTheoplayer() {
// player = THEOplayer(...)
let airPlayState = theoplayer.cast?.airPlay?.state
let isCasting = theoplayer.cast?.airPlay?.casting
// ...
// if (want to start AirPlay)
theoplayer.cast?.airPlay?.start()
// if (want to stop AirPlay)
theoplayer.cast?.airPlay?.stop()
// ...
theoplayer.cast?.airPlay?.addEventListener(type: AirPlayEventTypes.STATE_CHANGE, listener: onStateChange)
}

private func onStateChange(event: AirPlayStateChangeEvent) {
if (event.state == PlayerCastState.available) {
// show AirPlay available icon
} else if (event.state == PlayerCastState.connected) {
// show AirPlay connected icon
}
print(event.state)
print(self.player.cast?.airPlay?.casting)
}

Remarks

  • Chromecast and AirPlay are comparable technologies.