Disabled tunneling on Hi3798MV200

This commit is contained in:
Robin 2021-03-31 16:38:50 +02:00
parent 5739caaa5a
commit 4a9d21062a
2 changed files with 26 additions and 2 deletions

View File

@ -74,6 +74,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.SubtitleView; import com.google.android.exoplayer2.ui.SubtitleView;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoListener; import com.google.android.exoplayer2.video.VideoListener;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoader;
@ -488,8 +489,13 @@ public final class Player implements
// Setup subtitle view // Setup subtitle view
simpleExoPlayer.addTextOutput(binding.subtitleView); simpleExoPlayer.addTextOutput(binding.subtitleView);
// Setup audio session with onboard equalizer // enable media tunneling
trackSelector.setParameters(trackSelector.buildUponParameters().setTunnelingEnabled(true)); if (DeviceUtils.shouldSupportMediaTunneling()) {
trackSelector.setParameters(
trackSelector.buildUponParameters().setTunnelingEnabled(true));
} else if (DEBUG) {
Log.d(TAG, "[" + Util.DEVICE_DEBUG_INFO + "] does not support media tunneling");
}
} }
private void initListeners() { private void initListeners() {

View File

@ -20,6 +20,13 @@ public final class DeviceUtils {
private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv"; private static final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
private static Boolean isTV = null; private static Boolean isTV = null;
/*
* Devices that do not support media tunneling
*/
// Formuler Z8 Pro, Z8, CC, Z Alpha, Z+ Neo
private static final boolean HI3798MV200 = Build.VERSION.SDK_INT == 24
&& Build.DEVICE.equals("Hi3798MV200");
private DeviceUtils() { private DeviceUtils() {
} }
@ -88,4 +95,15 @@ public final class DeviceUtils {
sp, sp,
context.getResources().getDisplayMetrics()); context.getResources().getDisplayMetrics());
} }
/**
* Some devices have broken tunneled video playback but claim to support it.
* See https://github.com/TeamNewPipe/NewPipe/issues/5911
* @return false if Kitkat (does not support tunneling) or affected device
*/
public static boolean shouldSupportMediaTunneling() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& !HI3798MV200;
}
} }