mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-25 04:22:30 +01:00
fucking android bullshit
This commit is contained in:
parent
3cf81230b2
commit
d82274f5d4
@ -145,10 +145,6 @@ public abstract class BasePlayer implements
|
||||
|
||||
@Nullable protected Toast errorToast;
|
||||
|
||||
/** Will remember the last playback state even if simpleExoPlayer ot destroyed */
|
||||
private int lastPlaybackState;
|
||||
private boolean lastPlayWhenReady;
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Player
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
@ -277,8 +273,6 @@ public abstract class BasePlayer implements
|
||||
public void destroyPlayer() {
|
||||
if (DEBUG) Log.d(TAG, "destroyPlayer() called");
|
||||
if (simpleExoPlayer != null) {
|
||||
lastPlaybackState = simpleExoPlayer.getPlaybackState();
|
||||
lastPlayWhenReady = simpleExoPlayer.getPlayWhenReady();
|
||||
simpleExoPlayer.removeListener(this);
|
||||
simpleExoPlayer.stop();
|
||||
simpleExoPlayer.release();
|
||||
@ -1112,9 +1106,9 @@ public abstract class BasePlayer implements
|
||||
}
|
||||
|
||||
public boolean isPlaying() {
|
||||
final int state = getLastPlaybackState();
|
||||
final int state = simpleExoPlayer.getPlaybackState();
|
||||
return (state == Player.STATE_READY || state == Player.STATE_BUFFERING)
|
||||
&& getLastPlayWhenReady();
|
||||
&& simpleExoPlayer.getPlayWhenReady();
|
||||
}
|
||||
|
||||
@Player.RepeatMode
|
||||
@ -1188,21 +1182,7 @@ public abstract class BasePlayer implements
|
||||
playQueue.setRecovery(queuePos, windowPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sometimes the playbac kstate gets asked even though simpleExoPlayer got already destroyed.
|
||||
* Therefore on destroying simpleExoPlayer the playback state will get asked once more, so
|
||||
* you can retreve the last playback state here.
|
||||
* @return the playback state of simpleExoPlayer even if got destroyed
|
||||
*/
|
||||
public int getLastPlaybackState() {
|
||||
return simpleExoPlayer == null
|
||||
? lastPlaybackState
|
||||
: simpleExoPlayer.getPlaybackState();
|
||||
}
|
||||
|
||||
public boolean getLastPlayWhenReady() {
|
||||
return simpleExoPlayer == null
|
||||
? lastPlayWhenReady
|
||||
: simpleExoPlayer.getPlayWhenReady();
|
||||
public boolean gotDestroyed() {
|
||||
return simpleExoPlayer == null;
|
||||
}
|
||||
}
|
||||
|
@ -217,10 +217,9 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||
if (playerImpl == null) return;
|
||||
|
||||
playerImpl.setRecovery();
|
||||
playerState = new PlayerState(playerImpl.getPlayQueue(), playerImpl.getRepeatMode(),
|
||||
playerImpl.getPlaybackSpeed(), playerImpl.getPlaybackPitch(),
|
||||
playerImpl.getPlaybackQuality(), playerImpl.getPlaybackSkipSilence(),
|
||||
playerImpl.isPlaying());
|
||||
if(!playerImpl.gotDestroyed()) {
|
||||
playerState = createPlayerState();
|
||||
}
|
||||
StateSaver.tryToSave(isChangingConfigurations(), null, outState, this);
|
||||
}
|
||||
|
||||
@ -235,6 +234,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||
if (!isBackPressed) {
|
||||
playerImpl.minimize();
|
||||
}
|
||||
playerState = createPlayerState();
|
||||
playerImpl.destroy();
|
||||
|
||||
isInMultiWindow = false;
|
||||
@ -245,6 +245,13 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||
// State Saving
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
private PlayerState createPlayerState() {
|
||||
return new PlayerState(playerImpl.getPlayQueue(), playerImpl.getRepeatMode(),
|
||||
playerImpl.getPlaybackSpeed(), playerImpl.getPlaybackPitch(),
|
||||
playerImpl.getPlaybackQuality(), playerImpl.getPlaybackSkipSilence(),
|
||||
playerImpl.isPlaying());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateSuffix() {
|
||||
return "." + UUID.randomUUID().toString() + ".player";
|
||||
|
@ -14,3 +14,6 @@
|
||||
- Fix time parsing for . format, so NewPipe can be used in Finland
|
||||
- Fix subscription count
|
||||
- Add foreground service permission for API 28+ devices #1830
|
||||
|
||||
### Known Bugs
|
||||
- Playback state can not be saved on Android P
|
||||
|
Loading…
Reference in New Issue
Block a user