# How to programmatically detect audio track changes on iOS

This article describes how you can use the AudioTrack API to detect audio track changes. An audio track "change" is triggered by enabling (or disabling) an audio track.

Implementing this functionality is a common use-case for developers who want to build their own UI, and annotate the audio track that is currently active.

## Usage

The implementation of the iOS SDK applies to all iOS-based platforms, including iPadOS and tvOS.

The iOS SDK exposes the AudioTrack API through [`player.audioTracks`](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/v11/api-reference/ios/Classes/THEOplayer#/s:13THEOplayerSDK0A0C11audioTracksAA14AudioTrackList_pvp). This `audioTracks` property is a [`MediaTrackList`](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/v11/api-reference/ios/Protocols/MediaTrackList). This `MediaTrackList` dispatches the events from the [`AudioTrackListEventTypes`](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/v11/api-reference/ios/Structs/AudioTrackListEventTypes). The `AudioTrackListEventTypes` contains the [`CHANGE`](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/v11/api-reference/ios/Structs/AudioTrackListEventTypes#/s:13THEOplayerSDK24AudioTrackListEventTypesV6CHANGEAA0F4TypeCyAA0d6ChangeF0CGvpZ) event, as well as the `ADD_TRACK` and `REMOVE_TRACK` event.

The code below allows you to detect audio track changes.

```swift
player?.audioTracks.addEventListener(type: AudioTrackListEventTypes.CHANGE, listener: { event in
    let track: AudioTrack = event.track as! AudioTrack
    print(track.label, track.language, track.enabled)
})
```

The properties of a media `track` (e.g. `enabled`, `language`) are described in the [`MediaTrack`](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/v11/api-reference/ios/Protocols/MediaTrack) and [`Track`](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/v11/api-reference/ios/Protocols/Track) API references.

## Related articles

Are you reading this article because you are interested in audio tracks? Continue reading below.

* [How to programmatically detect audio tracks](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/media-tracks/detect-audio-tracks.md)
* [How to programmatically enable or disable audio tracks](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/media-tracks/enable-disable-audio-tracks.md)

Are you reading this article because you are implementing a custom UI? Then you will find the following articles interesting:

* [How to build a chromeless UI](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/ui/build-chromeless-ui.md)
* [How to detect video track quality changes](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/media-tracks/detect-video-track-quality-changes.md)
* [How to detect text track changes](https://docs-preview.optiview.dolby.com/pr-860/theoplayer/how-to-guides/ios/text-tracks/detect-text-track-changes.md)
