HlsChunkSource initial formatIndex to first variant, can we provide an option to pick a different variant?
It seems when HlsChunkSource is initialized, we will pick the first enabled variant, I see this block of code in HlsChunkSource:
// Select the first variant from the master playlist that's enabled. int minEnabledVariantIndex = Integer.MAX_VALUE; for (int i = 0; i < enabledFormats.length; i++) { int variantIndex = getVariantIndex(enabledFormats[i]); if (variantIndex < minEnabledVariantIndex) { minEnabledVariantIndex = variantIndex; formatIndex = i; } }
so it's quite random that what the initial variant will be. For example, most of the playlists I am looking at are putting low quality variant in the front, so I end up always playing low quality video upfront for the first 15 seconds or so, and later the bandwidth meter kicks in and pick a different variant that fits the current network condition. What if I want to start with a higher quality variant upfront? Maybe a parameter like "initBandWidth" so HlsChunkSource can pick the initial variant base on that bandwidth I provide.
Or is this some kind of HLS spec that I am missing, that the player should always start with the first variant?
According to Apple: "The first entry in the variant playlist will be played at the initiation of a stream and is used as part of a test to determine which stream is most appropriate". See https://developer.apple.com/library/ios/technotes/tn2224/_index.html.
This makes sense. The player should respect the spec, and if we want to "play higher quality variant upfront", the playlist generator should put a higher quality variant in the front, or we can make some one-off fix in our app to customize the HlsChunkSource. Thanks a lot for the reference, and your super quick response as always. ojw28 you rock.
The playlist generator should probably do this. Equally, I think it's ok in practice for a player to exercise some common sense and pick a different variant if it think that it knows better. We don't provide this option currently, but may do so at some point in the future.