Skip to content

Commit

Permalink
Improve code style and fix some warnings
Browse files Browse the repository at this point in the history
Removed a textTrack null check on a now- NonNull method
Added a error type switch case (TIMEOUT)
  • Loading branch information
Stypox committed Feb 16, 2021
1 parent eba0b07 commit 8978187
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ public float getPlaybackPitch() {
}

public boolean getPlaybackSkipSilence() {
return simpleExoPlayer != null
return !exoPlayerIsNull() && simpleExoPlayer.getAudioComponent() != null
&& simpleExoPlayer.getAudioComponent().getSkipSilenceEnabled();
}

Expand All @@ -1460,7 +1460,9 @@ public void setPlaybackParameters(final float speed, final float pitch,
savePlaybackParametersToPrefs(this, roundedSpeed, roundedPitch, skipSilence);
simpleExoPlayer.setPlaybackParameters(
new PlaybackParameters(roundedSpeed, roundedPitch));
simpleExoPlayer.getAudioComponent().setSkipSilenceEnabled(skipSilence);
if (simpleExoPlayer.getAudioComponent() != null) {
simpleExoPlayer.getAudioComponent().setSkipSilenceEnabled(skipSilence);
}
}
//endregion

Expand Down Expand Up @@ -2336,6 +2338,7 @@ public void onPlayerError(@NonNull final ExoPlaybackException error) {
case ExoPlaybackException.TYPE_OUT_OF_MEMORY:
case ExoPlaybackException.TYPE_REMOTE:
case ExoPlaybackException.TYPE_RENDERER:
case ExoPlaybackException.TYPE_TIMEOUT:
default:
showUnrecoverableError(error);
onPlaybackShutdown();
Expand Down Expand Up @@ -3358,7 +3361,7 @@ private void onTextTracksChanged() {
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ public boolean retainBackBufferFromKeyframe() {

@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
Expand Down

0 comments on commit 8978187

Please sign in to comment.