Feature #3320

Auto refresh rate switch option for Android version via Android 6+ API

Added by Yuri Yuriev about 3 years ago.

Status:NewStart date:10/22/2017
Priority:NormalDue date:
Assignee:Andreas Smas% Done:

0%

Category:Video playback
Target version:-

Description

Hi! Is it possible to add auto refresh rate switch option for Android version via standart Android 6+ API — preferredDisplayModeId? It's supported on some new TV boxes like: Nvidia Shield, Minix Neo U9-H, Ugoos AM3, Fire TV 2+, etc. Here is the sample, just the simple function:

public void prepareDisplay(float fps) {

Display display = getWindowManager().getDefaultDisplay();
WindowManager.LayoutParams windowLayoutParams = getWindow().getAttributes();

float doubleFps = fps;

if ((fps > 24.8 && fps < 25.2) || (fps > 29.7 && fps < 30.2)) doubleFps = fps * 2.0f;

List<Display.Mode> foundModes = new ArrayList<Display.Mode>();
List<Float> accuracy = new ArrayList<Float>();

Display.Mode bestMode = display.getMode();

for (Display.Mode candidate : display.getSupportedModes()) {

boolean refreshRateOk = Math.round(candidate.getRefreshRate()) == Math.round(doubleFps);
boolean resolutionOk = candidate.getPhysicalWidth() == bestMode.getPhysicalWidth() &&
candidate.getPhysicalHeight() == bestMode.getPhysicalHeight();

if ((!refreshRateOk) || (!resolutionOk)) {
continue;
}

foundModes.add(candidate);
accuracy.add(Math.abs(candidate.getRefreshRate() - doubleFps));
}

if (foundModes.isEmpty()) {
windowLayoutParams.preferredDisplayModeId = 0;
return;
}

int minIndex;
minIndex = accuracy.indexOf(Collections.min(accuracy));

windowLayoutParams.preferredDisplayModeId = foundModes.get(minIndex).getModeId();
}

23,976 fps > 23,976 Hz (or 24 Hz if 23,976 Hz not supported)
24 fps > 24 Hz
25 fps or 50 fps > 50 Hz
29,97 fps or 59,94 fps > 59,94 Hz (or 60 Hz if 59,94 Hz not supported)
30 fps or 60 fps > 60 Hz

Also available in: Atom PDF