1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

-Updated ExoPlayer to 2.8.1, fixing livestream with long duration not loading.

-Updated OkHttp to 3.10.0 and RxJava to 2.1.14.
-Changed player recovery seek to use ExoPlayer built-in window seeking instead of seeking after stream window starts playing.
-Changed playback speed changer default step size to 25%.
-Changed player notification to reset on all state changes.
-Fixed gradle dependency version incorrect variable names.
-Fixed video player double tap not working during pause.
-[#1412] Fixed NPE when sharing video to main video activity when it was playing but is out of focus: Reset main player state when new intent is received.
-[#1410] Fixed fast forwarding and rewinding not working within 10 seconds from beginning or end of a stream window.
This commit is contained in:
John Zhen Mo 2018-05-23 19:56:43 -07:00
parent f1f5996975
commit 0ece4851d2
6 changed files with 36 additions and 53 deletions

View File

@ -42,7 +42,7 @@ android {
ext {
supportLibVersion = '27.1.1'
exoPlayerLibVersion = '2.8.0'
exoPlayerLibVersion = '2.8.1'
roomDbLibVersion = '1.1.1'
leakCanaryLibVersion = '1.5.4'
okHttpLibVersion = '3.10.0'

View File

@ -544,26 +544,29 @@ public final class BackgroundPlayer extends Service {
@Override
public void changeState(int state) {
resetNotification();
super.changeState(state);
updatePlayback();
updateNotification(-1);
}
@Override
public void onBlocked() {
super.onBlocked();
updateNotification(-1);
startForeground(NOTIFICATION_ID, notBuilder.build());
}
@Override
public void onBuffering() {
super.onBuffering();
updateNotification(-1);
startForeground(NOTIFICATION_ID, notBuilder.build());
}
@Override
public void onPausedSeek() {
super.onPausedSeek();
updateNotification(-1);
startForeground(NOTIFICATION_ID, notBuilder.build());
}
@ -589,7 +592,6 @@ public final class BackgroundPlayer extends Service {
public void onCompleted() {
super.onCompleted();
resetNotification();
if (bigNotRemoteView != null) bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, 100, 100, false);
if (notRemoteView != null) notRemoteView.setProgressBar(R.id.notificationProgressBar, 100, 100, false);
updateNotification(R.drawable.ic_replay_white);

View File

@ -85,7 +85,6 @@ import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_INTERNAL
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_PERIOD_TRANSITION;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK;
import static com.google.android.exoplayer2.Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT;
import static org.schabi.newpipe.player.helper.PlayerHelper.getTimeString;
/**
* Base for the players, joining the common properties
@ -157,7 +156,6 @@ public abstract class BasePlayer implements
protected MediaSessionManager mediaSessionManager;
private boolean isPrepared = false;
private boolean isSynchronizing = false;
//////////////////////////////////////////////////////////////////////////*/
@ -575,37 +573,17 @@ public abstract class BasePlayer implements
private void maybeCorrectSeekPosition() {
if (playQueue == null || simpleExoPlayer == null || currentMetadata == null) return;
final int currentSourceIndex = playQueue.getIndex();
final PlayQueueItem currentSourceItem = playQueue.getItem();
final StreamInfo currentInfo = currentMetadata.getMetadata();
if (currentSourceItem == null) return;
final long recoveryPositionMillis = currentSourceItem.getRecoveryPosition();
final boolean isCurrentWindowCorrect =
simpleExoPlayer.getCurrentPeriodIndex() == currentSourceIndex;
final StreamInfo currentInfo = currentMetadata.getMetadata();
final long presetStartPositionMillis = currentInfo.getStartPosition() * 1000;
if (recoveryPositionMillis != PlayQueueItem.RECOVERY_UNSET && isCurrentWindowCorrect) {
// Is recovering previous playback?
if (DEBUG) Log.d(TAG, "Playback - Rewinding to recovery time=" +
"[" + getTimeString((int)recoveryPositionMillis) + "]");
seekTo(recoveryPositionMillis);
playQueue.unsetRecovery(currentSourceIndex);
} else if (isSynchronizing && isLive()) {
// Is still synchronizing?
if (DEBUG) Log.d(TAG, "Playback - Synchronizing livestream to default time");
//seekToDefault();
} else if (isSynchronizing && presetStartPositionMillis > 0L) {
if (presetStartPositionMillis > 0L) {
// Has another start position?
if (DEBUG) Log.d(TAG, "Playback - Seeking to preset start " +
"position=[" + presetStartPositionMillis + "]");
seekTo(presetStartPositionMillis);
}
isSynchronizing = false;
}
/**
@ -784,16 +762,18 @@ public abstract class BasePlayer implements
"index=[" + currentPlayQueueIndex + "] with " +
"playlist length=[" + currentPlaylistSize + "]");
// If not playing correct stream, change window position and sets flag
// for synchronizing once window position is corrected
// @see maybeCorrectSeekPosition()
} else if (currentPlaylistIndex != currentPlayQueueIndex || onPlaybackInitial ||
!isPlaying()) {
if (DEBUG) Log.d(TAG, "Playback - Rewinding to correct" +
" index=[" + currentPlayQueueIndex + "]," +
" from=[" + currentPlaylistIndex + "], size=[" + currentPlaylistSize + "].");
isSynchronizing = true;
simpleExoPlayer.seekToDefaultPosition(currentPlayQueueIndex);
if (item.getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET) {
simpleExoPlayer.seekTo(currentPlayQueueIndex, item.getRecoveryPosition());
playQueue.unsetRecovery(currentPlayQueueIndex);
} else {
simpleExoPlayer.seekToDefaultPosition(currentPlayQueueIndex);
}
}
}
@ -936,9 +916,7 @@ public abstract class BasePlayer implements
public void seekTo(long positionMillis) {
if (DEBUG) Log.d(TAG, "seekBy() called with: position = [" + positionMillis + "]");
if (simpleExoPlayer == null || positionMillis < 0 ||
positionMillis > simpleExoPlayer.getDuration()) return;
simpleExoPlayer.seekTo(positionMillis);
if (simpleExoPlayer != null) simpleExoPlayer.seekTo(positionMillis);
}
public void seekBy(long offsetMillis) {

View File

@ -896,7 +896,6 @@ public final class MainVideoPlayer extends AppCompatActivity
@Override
public boolean onDoubleTap(MotionEvent e) {
if (DEBUG) Log.d(TAG, "onDoubleTap() called with: e = [" + e + "]" + "rawXy = " + e.getRawX() + ", " + e.getRawY() + ", xy = " + e.getX() + ", " + e.getY());
if (!playerImpl.isPlaying()) return false;
if (e.getX() > playerImpl.getRootView().getWidth() * 2 / 3) {
playerImpl.onFastForward();

View File

@ -683,9 +683,9 @@ public final class PopupVideoPlayer extends Service {
@Override
public void changeState(int state) {
resetNotification();
super.changeState(state);
updatePlayback();
updateNotification(-1);
}
@Override

View File

@ -27,7 +27,13 @@ public class PlaybackParameterDialog extends DialogFragment {
public static final char STEP_UP_SIGN = '+';
public static final char STEP_DOWN_SIGN = '-';
public static final double DEFAULT_PLAYBACK_STEP_VALUE = 0.05f;
public static final double STEP_ONE_PERCENT_VALUE = 0.01f;
public static final double STEP_FIVE_PERCENT_VALUE = 0.05f;
public static final double STEP_TEN_PERCENT_VALUE = 0.10f;
public static final double STEP_TWENTY_FIVE_PERCENT_VALUE = 0.25f;
public static final double STEP_ONE_HUNDRED_PERCENT_VALUE = 1.00f;
public static final double DEFAULT_PLAYBACK_STEP_VALUE = STEP_TWENTY_FIVE_PERCENT_VALUE;
public static final double DEFAULT_TEMPO = 1.00f;
public static final double DEFAULT_PITCH = 1.00f;
@ -244,35 +250,33 @@ public class PlaybackParameterDialog extends DialogFragment {
stepSizeOneHundredPercentText = rootView.findViewById(R.id.stepSizeOneHundredPercent);
if (stepSizeOnePercentText != null) {
final double onePercent = 0.01f;
stepSizeOnePercentText.setText(getPercentString(onePercent));
stepSizeOnePercentText.setOnClickListener(view -> setupStepSize(onePercent));
stepSizeOnePercentText.setText(getPercentString(STEP_ONE_PERCENT_VALUE));
stepSizeOnePercentText.setOnClickListener(view ->
setupStepSize(STEP_ONE_PERCENT_VALUE));
}
if (stepSizeFivePercentText != null) {
final double fivePercent = 0.05f;
stepSizeFivePercentText.setText(getPercentString(fivePercent));
stepSizeFivePercentText.setOnClickListener(view -> setupStepSize(fivePercent));
stepSizeFivePercentText.setText(getPercentString(STEP_FIVE_PERCENT_VALUE));
stepSizeFivePercentText.setOnClickListener(view ->
setupStepSize(STEP_FIVE_PERCENT_VALUE));
}
if (stepSizeTenPercentText != null) {
final double tenPercent = 0.10f;
stepSizeTenPercentText.setText(getPercentString(tenPercent));
stepSizeTenPercentText.setOnClickListener(view -> setupStepSize(tenPercent));
stepSizeTenPercentText.setText(getPercentString(STEP_TEN_PERCENT_VALUE));
stepSizeTenPercentText.setOnClickListener(view ->
setupStepSize(STEP_TEN_PERCENT_VALUE));
}
if (stepSizeTwentyFivePercentText != null) {
final double twentyFivePercent = 0.25f;
stepSizeTwentyFivePercentText.setText(getPercentString(twentyFivePercent));
stepSizeTwentyFivePercentText.setText(getPercentString(STEP_TWENTY_FIVE_PERCENT_VALUE));
stepSizeTwentyFivePercentText.setOnClickListener(view ->
setupStepSize(twentyFivePercent));
setupStepSize(STEP_TWENTY_FIVE_PERCENT_VALUE));
}
if (stepSizeOneHundredPercentText != null) {
final double oneHundredPercent = 1.00f;
stepSizeOneHundredPercentText.setText(getPercentString(oneHundredPercent));
stepSizeOneHundredPercentText.setText(getPercentString(STEP_ONE_HUNDRED_PERCENT_VALUE));
stepSizeOneHundredPercentText.setOnClickListener(view ->
setupStepSize(oneHundredPercent));
setupStepSize(STEP_ONE_HUNDRED_PERCENT_VALUE));
}
}