-
Notifications
You must be signed in to change notification settings - Fork 615
Description
By default, DefaultTrackSelector
gets the display size from the physical screen to not select video tracks that are larger than the screen size
I'm struggling to figure out how to identify tracks that the track selector will never automatically select if they are larger than the screen size. For instance, if the screen size is 1280x720 and the stream I'm playing has a 1920x1080 track, the 1920x1080 track will never be automatically selected. As I understand it, when a track is larger than the screen size it is marked with SELECTION_ELIGIBILITY_NO, and when DefaultTrackSelector finds suitable tracks it skips tracks with SELECTION_ELIGIBILITY_NO. But as far as I can see this isn't exposed outside DefaultTrackSelector
From the demo app
// Pretend that the screen is 1280x720 (I added this in initializePlayer() just before the player is built)
trackSelectionParameters = trackSelectionParameters
.buildUpon()
.setViewportSize(1280, 720, true)
.build();
public void onTracksChanged(Tracks tracks) {
tracks.getGroups().forEach(group -> {
if (group.getType() == C.TRACK_TYPE_VIDEO) {
for (int i = 0; i < group.length; i++) {
Format format = group.getTrackFormat(i);
if (format.width > 0) {
System.out.println(
"VideoTrack: " + format.width + "x" + format.height + " isSupported="
+ group.isTrackSupported(i) + " isSelected=" + group.isTrackSelected(i));
}
}
}
});
...
}
When playing HLS -> Apple 16x9 basic stream (TS)
it prints out this:
VideoTrack: 416x234 isSupported=true isSelected=true
VideoTrack: 640x360 isSupported=true isSelected=true
VideoTrack: 960x540 isSupported=true isSelected=true
VideoTrack: 1280x720 isSupported=true isSelected=true
VideoTrack: 1920x1080 isSupported=true isSelected=false
So the 1920x1080 track is seen as supported because it is playable by the device, but it is not part of the automatic selection. We have a quality selector that works by setting a max quality with setMaxVideoSize()
on the track selector, so if the user chooses 960x540, the 1280x720 track will be marked as isSelected=false
as well. We would ideally like to remove 1920x1080 from the menu because it will never be able to be selected, but I'm not sure how I would identify which tracks are never going to be part of the track selectors selection, I don't want to just remove the tracks with isSelected=false
since that will potentially remove tracks that can be selected
I can check trackSelectionParameters.viewportWidth/viewportHeight
and remove tracks based on these, but I'm not sure if there are other constraints that can cause tracks to not be part of the selection that we would ideally also catch without having to add more logic in our app, where a flag that a track isn't selectable would be better to use