AirPlay Listener

Listen for AirPlay events with the JW Player iOS SDK


When the iOS device connects to or disconnects from an AirPlay device, the player detects and reacts to these connection and disconnection events. These events are surfaced through the JWAirPlayDelegate. The JWAirPlayDelegate can be assigned through the JWPlayer interface.

If you are using the JWPlayerViewController to create your user interface, the AirPlay button is automatically added to the player. When using the JWPlayerViewController, the jwplayer(_ player: JWPlayer, airPlayStatusChanged status: JWAirPlayStatus) method can be overridden to receive AirPlay status events.


// Subclass of JWPlayerViewController
class PlayerViewController: JWPlayerViewController {
    override func jwplayer(_ player: JWPlayer, airPlayStatusChanged status: JWAirPlayStatus) {
        super.jwplayer(player, airPlayStatusChanged: status)
        
        // Handle the event here.
    }
}
// Subclass of JWPlayerObjViewController
@implementation PlayerViewController

- (void)jwplayer:(id<JWPlayer>)player airPlayStatusChanged:(enum JWAirPlayStatus)status {
    [super jwplayer:player airPlayStatusChanged:status];
    
    // Handle the event here.
}

📘

The AirPlay button is displayed in the player automatically when utilizing the experience provided by JWPlayerViewController.

If you have implemented the player using only JWPlayerView, you will need to add an AirPlay button yourself, using Apple’s API. In this case, the JWAirPlayDelegate you have assigned to the JWPlayer object will still receive AirPlay status events.



Did this page help you?