Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to set initial AudioTrack index #5831

Closed
rangermanWSC opened this issue Sep 19, 2023 · 4 comments
Closed

How to set initial AudioTrack index #5831

rangermanWSC opened this issue Sep 19, 2023 · 4 comments

Comments

@rangermanWSC
Copy link

What do you want to do with Hls.js?

Hi, is there a way to set an initial audioTrack other then the default (0) ?
Because if I change it manually after the parsed event then I get some delay.

What have you tried so far?

No response

@rangermanWSC rangermanWSC added Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. Question labels Sep 19, 2023
@robwalch
Copy link
Collaborator

The initial audio track is selected on LEVEL_SWITCHING after AUDIO_TRACKS_UPDATED by picking the first option with DEFAULT=YES. To override, set hls.audioTrack on AUDIO_TRACKS_UPDATED. The index set should be from one of hls.audioTracks in AUDIO_TRACKS_UPDATED.

@robwalch robwalch added answered and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Sep 19, 2023
@robwalch robwalch changed the title Can't set an initial AudioTrack index How to set initial AudioTrack index Sep 19, 2023
@rangermanWSC
Copy link
Author

Thanks @robwalch, but my problem is that I want to decide what track to play dynamically from the code, and not change the manifest (so DEFAULT=YES will not help me).
And when I change the hls.audioTrack on the AUDIO_TRACKS_UPDATED I still get some delay and can hear the first audio for a short time.
I wondered why we can't pass the audioTrack index when we create the new HLS()

@robwalch
Copy link
Collaborator

robwalch commented Sep 20, 2023

when I change the hls.audioTrack on the AUDIO_TRACKS_UPDATED I still get some delay and can hear the first audio for a short time.

Is there audio in the main track? No other audio playlists are loaded when done properly. AUDIO_TRACKS_UPDATED is emitted before any audio is loaded so this sounds like either an error in your implementation or a bug. Please file one with steps to reproduce so that we can look into it.

I wondered why we can't pass the audioTrack index when we create the new HLS()

That's not yet a feature. See #5532.

robwalch added a commit that referenced this issue Oct 6, 2023
…h zero tracks

Allow selection of audioTrack on AUDIO_TRACKS_UPDATED (overriding default selection - Resolves #5831)
Cleanup selection of subtitleTrack on SUBTITLE_TRACKS_UPDATED (overriding default selection)
@robwalch
Copy link
Collaborator

robwalch commented Oct 6, 2023

Hi @rangermanWSC,

I just added a change in #5880 that should allow track selection in the AUDIO_TRACKS_UPDATED event handler. Let me know if this works for you. Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants