Supporting AirPods in your iOS and tvOS media Apps

David Cordero
2 min readOct 19, 2020

This post was original published in dcordero.me, where you will always find the most updated, and free of spyware version of all my posts.

The AirPods are equipped with sensors that allow users to trigger some gestures like double-tap or automatic ear detection, to control media playback.

The behavior of each of these gestures can be configured in the Settings of the operating system among the options: Siri, Play/Pause, Next Track, Previous Track, or Off.

By default, if you are using AVPlayerViewController, some of these gestures (like Play/Pause) will work out of the box.

The good news

If you are using your custom player, or you still need to extend the basic support provided by AVPlayerViewController, the good news is that the AirPods behave like any other Remote Control. In terms of development, that means that we can define our custom handlers for each gesture via MPRemoteCommandCenter.

Here you have an example of a simple player defining custom handlers for the gestures: Play/Pause, Next Track and Previous Track.

The bad news

The bad news (for tvOS) is that, since tvOS 14.0, MPRemoteCommandCenter is buggy and it does not longer work as expected. Hopefully Apple will eventually fix this topic.

You can find more information about this topic in the following thread in the Apple Developer Forums:

--

--

David Cordero

iOS and tvOS developer at Zattoo. Passionate about coding and lifelong learning.