You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Better Player only provides an initialized event to indicate that playback can start. However, in adaptive streaming scenarios (HLS/DASH), the parsing of track metadata (e.g., subtitles, audio variants, and quality levels) may finish slightly after the player is technically “initialized.” This often forces developers to rely on “hacky” solutions—like manual delays, repeated polling, or retries—to ensure all track data is fully available before showing custom track-selection UI.
Problem
The initialized event doesn’t guarantee that betterPlayerAsmsAudioTracks, betterPlayerSubtitlesSourceList, or betterPlayerAsmsTracks are populated.
Attempts to access these properties immediately after initialized can result in null data, leading to runtime exceptions (e.g., _TypeError (Null check operator used on a null value)) if not carefully handled.
Developers must implement non-trivial delay or retry logic to safely fetch the complete metadata.
Proposed Solution
Introduce a new event—something like metadataReady or tracksDiscovered—fired only when all adaptive track metadata is confirmed loaded and available.
This event would give developers a clear signal to safely fetch and display any audio/subtitle/quality data without concern for null references.
Benefits
Cleaner code: Eliminates the need for manual “delay” or “retry” patterns that are prone to timing issues.
More predictable UX: Ensures custom controls can reliably display a complete list of tracks.
Fewer bugs and exceptions: Minimizes null reference errors and confusion about when metadata is ready.
Potential Implementation
Hook the new event emission into the logic that sets or updates betterPlayerAsmsAudioTracks, betterPlayerSubtitlesSourceList, and betterPlayerAsmsTracks.
Once the library confirms these lists are fully parsed (not null, even if empty), trigger BetterPlayerEventType.metadataReady.
This event could also be refired if the track list changes mid-stream (e.g., live streams or dynamically updated manifests).
The text was updated successfully, but these errors were encountered:
Currently, Better Player only provides an initialized event to indicate that playback can start. However, in adaptive streaming scenarios (HLS/DASH), the parsing of track metadata (e.g., subtitles, audio variants, and quality levels) may finish slightly after the player is technically “initialized.” This often forces developers to rely on “hacky” solutions—like manual delays, repeated polling, or retries—to ensure all track data is fully available before showing custom track-selection UI.
Problem
The initialized event doesn’t guarantee that betterPlayerAsmsAudioTracks, betterPlayerSubtitlesSourceList, or betterPlayerAsmsTracks are populated.
Attempts to access these properties immediately after initialized can result in null data, leading to runtime exceptions (e.g., _TypeError (Null check operator used on a null value)) if not carefully handled.
Developers must implement non-trivial delay or retry logic to safely fetch the complete metadata.
Proposed Solution
Introduce a new event—something like metadataReady or tracksDiscovered—fired only when all adaptive track metadata is confirmed loaded and available.
This event would give developers a clear signal to safely fetch and display any audio/subtitle/quality data without concern for null references.
Benefits
Cleaner code: Eliminates the need for manual “delay” or “retry” patterns that are prone to timing issues.
More predictable UX: Ensures custom controls can reliably display a complete list of tracks.
Fewer bugs and exceptions: Minimizes null reference errors and confusion about when metadata is ready.
Potential Implementation
Hook the new event emission into the logic that sets or updates betterPlayerAsmsAudioTracks, betterPlayerSubtitlesSourceList, and betterPlayerAsmsTracks.
Once the library confirms these lists are fully parsed (not null, even if empty), trigger BetterPlayerEventType.metadataReady.
This event could also be refired if the track list changes mid-stream (e.g., live streams or dynamically updated manifests).
The text was updated successfully, but these errors were encountered: