Improve code style and fix some warnings

Removed a textTrack null check on a now- NonNull method
Added a error type switch case (TIMEOUT)
This commit is contained in:
Stypox 2021-02-16 16:54:44 +01:00
parent eba0b07782
commit 8978187c64
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 10 additions and 6 deletions

View File

@ -1433,7 +1433,7 @@ public final class Player implements
}
public boolean getPlaybackSkipSilence() {
return simpleExoPlayer != null
return !exoPlayerIsNull() && simpleExoPlayer.getAudioComponent() != null
&& simpleExoPlayer.getAudioComponent().getSkipSilenceEnabled();
}
@ -1460,7 +1460,9 @@ public final class Player implements
savePlaybackParametersToPrefs(this, roundedSpeed, roundedPitch, skipSilence);
simpleExoPlayer.setPlaybackParameters(
new PlaybackParameters(roundedSpeed, roundedPitch));
simpleExoPlayer.getAudioComponent().setSkipSilenceEnabled(skipSilence);
if (simpleExoPlayer.getAudioComponent() != null) {
simpleExoPlayer.getAudioComponent().setSkipSilenceEnabled(skipSilence);
}
}
//endregion
@ -2336,6 +2338,7 @@ public final class Player implements
case ExoPlaybackException.TYPE_OUT_OF_MEMORY:
case ExoPlaybackException.TYPE_REMOTE:
case ExoPlaybackException.TYPE_RENDERER:
case ExoPlaybackException.TYPE_TIMEOUT:
default:
showUnrecoverableError(error);
onPlaybackShutdown();
@ -3358,7 +3361,7 @@ public final class Player implements
final List<String> availableLanguages = new ArrayList<>(textTracks.length);
for (int i = 0; i < textTracks.length; i++) {
final TrackGroup textTrack = textTracks.get(i);
if (textTrack.length > 0 && textTrack.getFormat(0) != null) {
if (textTrack.length > 0) {
availableLanguages.add(textTrack.getFormat(0).language);
}
}

View File

@ -81,12 +81,13 @@ public class LoadController implements LoadControl {
@Override
public boolean shouldContinueLoading(final long playbackPositionUs,
final long bufferedDurationUs, final float playbackSpeed) {
final long bufferedDurationUs,
final float playbackSpeed) {
if (!preloadingEnabled) {
return false;
}
return internalLoadControl.shouldContinueLoading(playbackPositionUs, bufferedDurationUs,
playbackSpeed);
return internalLoadControl.shouldContinueLoading(
playbackPositionUs, bufferedDurationUs, playbackSpeed);
}
@Override