|
|
|
|
@ -41,7 +41,7 @@ import io.github.anilbeesetti.nextlib.media3ext.ffdecoder.NextRenderersFactory; |
|
|
|
|
public class ExoUtil { |
|
|
|
|
|
|
|
|
|
public static ExoPlayer buildPlayer(int decode, Player.Listener listener) { |
|
|
|
|
ExoPlayer player = new ExoPlayer.Builder(App.get()).setLoadControl(buildLoadControl()).setTrackSelector(buildTrackSelector()).setRenderersFactory(buildRenderersFactory(decode == PlayerEngine.HARD ? DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON : DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER)).setMediaSourceFactory(buildMediaSourceFactory()).build(); |
|
|
|
|
ExoPlayer player = new ExoPlayer.Builder(App.get()).setLoadControl(buildLoadControl()).setTrackSelector(buildTrackSelector()).setRenderersFactory(buildRenderersFactory(getRenderMode(decode))).setMediaSourceFactory(buildMediaSourceFactory()).build(); |
|
|
|
|
if (BuildConfig.DEBUG) player.addAnalyticsListener(new EventLogger()); |
|
|
|
|
player.setAudioAttributes(AudioAttributes.DEFAULT, true); |
|
|
|
|
player.setHandleAudioBecomingNoisy(true); |
|
|
|
|
@ -65,8 +65,8 @@ public class ExoUtil { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String getMimeType(int errorCode) { |
|
|
|
|
if (errorCode == PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED || errorCode == PlaybackException.ERROR_CODE_PARSING_MANIFEST_MALFORMED) return MimeTypes.APPLICATION_OCTET_STREAM; |
|
|
|
|
if (errorCode == PlaybackException.ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED || errorCode == PlaybackException.ERROR_CODE_PARSING_CONTAINER_MALFORMED || errorCode == PlaybackException.ERROR_CODE_IO_UNSPECIFIED) return MimeTypes.APPLICATION_M3U8; |
|
|
|
|
if (errorCode == PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED || errorCode == PlaybackException.ERROR_CODE_PARSING_MANIFEST_MALFORMED) return MimeTypes.APPLICATION_OCTET_STREAM; |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -76,6 +76,10 @@ public class ExoUtil { |
|
|
|
|
return extras.keySet().stream().filter(key -> extras.getString(key) != null).collect(Collectors.toMap(key -> key, extras::getString)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static int getRenderMode(int decode) { |
|
|
|
|
return decode == PlayerEngine.HARD ? DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON : DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static LoadControl buildLoadControl() { |
|
|
|
|
return new DefaultLoadControl.Builder().setBufferDurationsMs(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS * Setting.getBuffer(), DefaultLoadControl.DEFAULT_MAX_BUFFER_MS * Setting.getBuffer(), DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS, DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS).build(); |
|
|
|
|
} |
|
|
|
|
|