# IOS Audio played does not match the one selected in player audio settings

**URL:** <https://community.bitmovin.com/t/ios-audio-played-does-not-match-the-one-selected-in-player-audio-settings/2776>\
**Category:** Support\
**Tags:** ios, bitmovin\
**Created:** [April 4, 2024, 10:04am UTC](https://community.bitmovin.com/t/ios-audio-played-does-not-match-the-one-selected-in-player-audio-settings/2776 "2024-04-04T10:04:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hengsopharuth94](https://avatars.discourse-cdn.com/v4/letter/h/e68b1a/32.png) [@hengsopharuth94](https://community.bitmovin.com/u/hengsopharuth94)\
**Post date:** [April 4, 2024, 10:04am UTC](https://community.bitmovin.com/t/ios-audio-played-does-not-match-the-one-selected-in-player-audio-settings/2776/1 "2024-04-04T10:04:48Z")

</div>

I have version Bitmovin on IOS 3.58.0.

Video \*\*\*\*\*.m3u8, Video has multiple audios (French, English, Korean…) and we set the default audio to Korean. When the source loaded the video did not play with Korean audio, but It played the video with French audio instead.

Even we use the setAudioTrack function

---

<div class="post-metadata">

**Author:** ![davidsteinacher](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/davidsteinacher/32/163_2.png) [@davidsteinacher](https://community.bitmovin.com/u/davidsteinacher)\
**Post date:** [April 4, 2024, 5:31pm UTC](https://community.bitmovin.com/t/ios-audio-played-does-not-match-the-one-selected-in-player-audio-settings/2776/2 "2024-04-04T17:31:30Z")

</div>

Hi @hengsopharuth94,

How do you specify the default audio? Is it specified in the HLS manifest using the `DEFAULT` flag?

> Even we use the setAudioTrack function

When in the lifecycle of the `Player` do you set this function? Ideally you call this after the Player is ready (aka. after an `ReadyEvent` was received)

---

<div class="post-metadata">

**Author:** ![admin.vodfactory](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/admin.vodfactory/32/438_2.png) [@admin.vodfactory](https://community.bitmovin.com/u/admin.vodfactory)\
**Post date:** [April 5, 2024, 4:29am UTC](https://community.bitmovin.com/t/ios-audio-played-does-not-match-the-one-selected-in-player-audio-settings/2776/3 "2024-04-05T04:29:57Z")

</div>

Hi @davidsteinacher,

While I cannot confirm yet the use of `setAudioTrack` in the player lifecycle, I can confirm that the HLS manifest contains the `DEFAULT` flag on the Korean audio track. It seems to be ignored, French audio is selected by default when opening the player.

Reproduced on:

- [Bitmovin’s Test Player](https://bitmovin.com/demos/stream-test?format=dash&manifest=https%3A%2F%2Fcdn.bitmovin.com%2Fcontent%2Fassets%2Fart-of-motion-dash-hls-progressive%2Fmpds%2Ff08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd)
- On [our OTT web platform](https://www.shadowz.fr/content/sea-fog-les-clandestins-96837), with macOS and Safari
- On [our iOS, iPadOS and tvOS apps](https://apps.apple.com/fr/app/shadowz/id1500269744)

 ![Screenshot 2024-04-05 at 10.20.46 in the morning](https://us1.discourse-cdn.com/flex015/uploads/bitmovin/original/1X/11882874c8df88b4d37c3a0ca363a5c855e57c70.png)

_Note: Due to confidentiality concerns, I cannot share the HLS manifest here. Let me know if I can get it to you in a secure manner._

---

<div class="post-metadata">

**Author:** ![davidsteinacher](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/davidsteinacher/32/163_2.png) [@davidsteinacher](https://community.bitmovin.com/u/davidsteinacher)\
**Post date:** [April 5, 2024, 8:19am UTC](https://community.bitmovin.com/t/ios-audio-played-does-not-match-the-one-selected-in-player-audio-settings/2776/4 "2024-04-05T08:19:18Z")

</div>

HI @admin.vodfactory,

thank you for sharing additional details and the content of the multivariant playlist.

What I can see there is that both audio tracks have the `AUTOSELECT` set to `YES`. This allows the player to select any of them even if it is not set as `DEFAULT` when the Player thinks there is a better-matching audio track.

On Apple platforms (including iOS), this happens, e.g. when the device language matches one of the tracks (or better matches them). I tested it with one of our reference streams with the same characteristics and could observe the same behaviour. (This is expected behaviour)

I could see two ways forward:

1. Setting `AUTOSELECT` to `NO` for all other audio tracks than the intended one
2. The second option is to manually select the desired audio track once the player is ready. This could be done by listening to the ReadyEvent and calling `setAudioTrack`. This could look something like this:

```swift
player
    .events
    .on(ReadyEvent.self)
    .sink { _ in
        guard let audioTrack = player.availableAudio.first(where: { $0.language == "de" }) else {
            return
        }

        player.setAudio(trackIdentifier: audioTrack.identifier)
    }
    .store(in: &cancelables)

```

I quickly tried this approach and could observe an issue (most likely similar to the issue you described in your initial post). It seems that there is a problem with the initial audio track selection and what we communicate on our API (the audio track communicated is actually not the selected one). I’ve raised this issue internally.

In the meantime, a potential workaround could be to switch the audio temporarily to another track. This, combined with the code above, could look like this:

```swift
player
    .events
    .on(ReadyEvent.self)
    .sink { _ in
        guard let desiredAudioTrack = player.availableAudio.first(where: { $0.language == "de" }) else {
            return
        }

        // Workaround to temporarily select a different audio track
        if let currentAudioTrack = player.audio, currentAudioTrack == desiredAudioTrack {
            guard let tmpAudioTrack = player.availableAudio.first(where: { $0 != currentAudioTrack }) else {
                return
            }

            player.setAudio(trackIdentifier: tmpAudioTrack.identifier)
        }

        player.setAudio(trackIdentifier: desiredAudioTrack.identifier)
    }
    .store(in: &cancelables)

```

* * *

> _Note: Due to confidentiality concerns, I cannot share the HLS manifest here. Let me know if I can get it to you in a secure manner._

Yes, you can get in touch with our support in the Bitmovin Dashboard at [Bitmovin Dashboard](https://bitmovin.com/dashboard) and [create a new support case](https://dashboard.bitmovin.com/support/tickets/create).

---

<div class="post-metadata">

**Author:** ![admin.vodfactory](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/admin.vodfactory/32/438_2.png) [@admin.vodfactory](https://community.bitmovin.com/u/admin.vodfactory)\
**Post date:** [April 5, 2024, 9:09am UTC](https://community.bitmovin.com/t/ios-audio-played-does-not-match-the-one-selected-in-player-audio-settings/2776/5 "2024-04-05T09:09:31Z")

</div>

Thanks @davidsteinacher for your feedback. We’ll most likely go with the workaround for now. Re-encoding our manifests to remove the `AUTOSELECT` attribute might be too heavy.

Could your team ping this topic when the problem would be fixed on an upcoming Bitmovin Player iOS SDK please?
