Skip to content

feat: Select default track by a list of preferences#9542

Open
KimKyuHoi wants to merge 31 commits intoshaka-project:mainfrom
KimKyuHoi:expand-language-configs
Open

feat: Select default track by a list of preferences#9542
KimKyuHoi wants to merge 31 commits intoshaka-project:mainfrom
KimKyuHoi:expand-language-configs

Conversation

@KimKyuHoi
Copy link
Contributor

@KimKyuHoi KimKyuHoi commented Dec 31, 2025

I went ahead and implemented the full structured preference system that was discussed in #1591.
Instead of just expanding languages to arrays, I replaced all 14 individual preference fields with 3 structured arrays:

  preferredAudio (language, role, label, channelCount, codec, spatialAudio)
  preferredText (language, role, format, forced)
  preferredVideo (label, role, codec, hdrLevel, layout)

Each array entry works as an AND filter - so you can say things like "I want Korean with 5.1 surround, but if not available, English is fine too":

player.configure('preferredAudio', [
  {language: 'ko', channelCount: 6},
  {language: 'ko'},
  {language: 'en'},
]);
image

Config - Replaced the 14 individual fields with 3 arrays of typed preference objects (AudioPreference, TextPreference, VideoPreference). The old fields still work at runtime with a deprecation warning, so existing apps won't break immediately.

Demo - The demo config UI now shows inline expandable preference lists instead of flat text inputs. You can add/remove entries and configure each field per entry. URL hash serialization was updated to use JSON format, with legacy param fallbacks preserved.

@KimKyuHoi KimKyuHoi changed the title Expand language configs feat(languages): expand language config to accept arrays Dec 31, 2025
@KimKyuHoi KimKyuHoi marked this pull request as ready for review December 31, 2025 04:33
@avelad
Copy link
Member

avelad commented Jan 5, 2026

Related to #1591

@avelad avelad added type: enhancement New feature or request priority: P2 Smaller impact or easy workaround labels Jan 5, 2026
@avelad avelad added this to the v5.0 milestone Jan 5, 2026
@shaka-bot
Copy link
Collaborator

shaka-bot commented Jan 5, 2026

Incremental code coverage: 71.76%

@tykus160
Copy link
Member

tykus160 commented Jan 7, 2026

FYI there was a discussion in topic linked and instead of your proposal, we were thinking about more configurable objects, see #1591 (comment), #1591 (comment) & #1591 (comment)

@matvp91
Copy link
Member

matvp91 commented Jan 7, 2026

I appreciate the effort, but I'm not confident this would hold up over time. I would strongly prefer reducing the set of streams using a list of preferences (see the linked comments from @tykus160).

Allowing multiple languages introduces questions around multiple roles, codecs, and their possible combinations. The recent text track simplification likely makes integration more straightforward. We should be careful introducing this as a proper v5 API as we'll have to maintain backwards compatibility for a while.

@KimKyuHoi, would you be willing to experiment with the proposed idea's in #1591 as opposed to solely allowing multiple languages?

@KimKyuHoi
Copy link
Contributor Author

@matvp91 Ah, I totally misunderstood (@avelad comment)! I thought that meant I had to maintain backwards compatibility. Thanks for clarifying that it's a breaking change release. That definitely makes the implementation simpler/cleaner. I will proceed without supporting the legacy config.

@matvp91
Copy link
Member

matvp91 commented Jan 7, 2026

Yes, we can break backwards compatibility with the introduction of a next major version.

I'm sorry I'm expanding scope so much for a change that should be relatively straight forward, but I feel we shall take advantage of the fact that we're going to bump a major version in order to get track preferences right from the get go. Nonetheless, we're here to help.

@tykus160, do you think implementing this in shaka.media.PreferenceBasedCriteria is a good strategy?

I'd love to hear everyone else's opinion though!

@KimKyuHoi
Copy link
Contributor Author

@matvp91 I think it's a good suggestion. Then, why don't we open a new issue, create a relation, and proceed further? I'm making this suggestion because I'm going to be taking charge of it anyway. I was concerned that if we proceeded with the existing PR, the resulting diff files would be too large.

@matvp91
Copy link
Member

matvp91 commented Jan 22, 2026

@KimKyuHoi what works best for you, I'm OK either way.

@shaka-project shaka-project deleted a comment Feb 2, 2026
@KimKyuHoi
Copy link
Contributor Author

@matvp91 Oh, you've been waiting a long time, right? Sorry. I'll work on this repo.

@avelad avelad modified the milestones: v5.0, v5.1 Feb 6, 2026
@avelad
Copy link
Member

avelad commented Feb 12, 2026

Please update PR title and descripcion with the new changes.

@avelad avelad linked an issue Feb 12, 2026 that may be closed by this pull request
@shaka-bot
Copy link
Collaborator

shaka-bot commented Feb 12, 2026

Bundle Size Report for PR #9542

File HEAD Base Diff
build_state.json 0.8 KiB (0.5 KiB) 0.8 KiB (0.5 KiB) 0.0 KiB
controls.css 23.3 KiB (4.9 KiB) 23.3 KiB (4.9 KiB) 0.0 KiB
demo.compiled.debug.js 244.3 KiB (49.1 KiB) 240.0 KiB (48.3 KiB) +4.2 KiB
demo.compiled.js 244.3 KiB (49.1 KiB) 240.0 KiB (48.3 KiB) +4.2 KiB
demo.css 170.3 KiB (27.8 KiB) 169.9 KiB (27.7 KiB) +0.4 KiB
locales.js 42.6 KiB (10.6 KiB) 42.6 KiB (10.6 KiB) 0.0 KiB
receiver.compiled.debug.js 144.0 KiB (23.8 KiB) 144.0 KiB (23.8 KiB) 0.0 KiB
receiver.compiled.js 144.0 KiB (23.8 KiB) 144.0 KiB (23.8 KiB) 0.0 KiB
shaka-player.compiled.debug.js 1494.7 KiB (341.9 KiB) 1492.7 KiB (341.1 KiB) +2.0 KiB
shaka-player.compiled.js 750.2 KiB (242.9 KiB) 748.3 KiB (242.2 KiB) +1.9 KiB
shaka-player.dash.debug.js 1093.7 KiB (255.5 KiB) 1091.8 KiB (254.9 KiB) +1.9 KiB
shaka-player.dash.js 516.2 KiB (170.9 KiB) 514.4 KiB (170.4 KiB) +1.8 KiB
shaka-player.experimental.debug.js 1876.9 KiB (422.0 KiB) 1874.9 KiB (421.2 KiB) +2.0 KiB
shaka-player.experimental.js 985.8 KiB (307.4 KiB) 983.8 KiB (306.7 KiB) +1.9 KiB
shaka-player.hls.debug.js 1129.8 KiB (261.5 KiB) 1127.9 KiB (260.8 KiB) +1.9 KiB
shaka-player.hls.js 553.8 KiB (182.3 KiB) 552.1 KiB (181.7 KiB) +1.8 KiB
shaka-player.ui.debug.js 1815.9 KiB (409.0 KiB) 1813.9 KiB (408.2 KiB) +2.0 KiB
shaka-player.ui.js 959.4 KiB (299.5 KiB) 957.5 KiB (298.8 KiB) +1.9 KiB

@matvp91 matvp91 changed the title feat(languages): expand language config to accept arrays feat: Select default track by a list of preferences Feb 12, 2026
@avelad
Copy link
Member

avelad commented Feb 13, 2026

@KimKyuHoi Please update the description of the PR to match with the current implementation!

@avelad avelad requested review from avelad and matvp91 February 13, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P2 Smaller impact or easy workaround type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand language config to a list

5 participants