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

View file

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