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;
|
@Nullable protected Toast errorToast;
|
||||||
|
|
||||||
/** Will remember the last playback state even if simpleExoPlayer ot destroyed */
|
|
||||||
private int lastPlaybackState;
|
|
||||||
private boolean lastPlayWhenReady;
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Player
|
// Player
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -277,8 +273,6 @@ public abstract class BasePlayer implements
|
||||||
public void destroyPlayer() {
|
public void destroyPlayer() {
|
||||||
if (DEBUG) Log.d(TAG, "destroyPlayer() called");
|
if (DEBUG) Log.d(TAG, "destroyPlayer() called");
|
||||||
if (simpleExoPlayer != null) {
|
if (simpleExoPlayer != null) {
|
||||||
lastPlaybackState = simpleExoPlayer.getPlaybackState();
|
|
||||||
lastPlayWhenReady = simpleExoPlayer.getPlayWhenReady();
|
|
||||||
simpleExoPlayer.removeListener(this);
|
simpleExoPlayer.removeListener(this);
|
||||||
simpleExoPlayer.stop();
|
simpleExoPlayer.stop();
|
||||||
simpleExoPlayer.release();
|
simpleExoPlayer.release();
|
||||||
|
@ -1112,9 +1106,9 @@ public abstract class BasePlayer implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlaying() {
|
public boolean isPlaying() {
|
||||||
final int state = getLastPlaybackState();
|
final int state = simpleExoPlayer.getPlaybackState();
|
||||||
return (state == Player.STATE_READY || state == Player.STATE_BUFFERING)
|
return (state == Player.STATE_READY || state == Player.STATE_BUFFERING)
|
||||||
&& getLastPlayWhenReady();
|
&& simpleExoPlayer.getPlayWhenReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Player.RepeatMode
|
@Player.RepeatMode
|
||||||
|
@ -1188,21 +1182,7 @@ public abstract class BasePlayer implements
|
||||||
playQueue.setRecovery(queuePos, windowPos);
|
playQueue.setRecovery(queuePos, windowPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean gotDestroyed() {
|
||||||
* Sometimes the playbac kstate gets asked even though simpleExoPlayer got already destroyed.
|
return simpleExoPlayer == null;
|
||||||
* 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,10 +217,9 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
if (playerImpl == null) return;
|
if (playerImpl == null) return;
|
||||||
|
|
||||||
playerImpl.setRecovery();
|
playerImpl.setRecovery();
|
||||||
playerState = new PlayerState(playerImpl.getPlayQueue(), playerImpl.getRepeatMode(),
|
if(!playerImpl.gotDestroyed()) {
|
||||||
playerImpl.getPlaybackSpeed(), playerImpl.getPlaybackPitch(),
|
playerState = createPlayerState();
|
||||||
playerImpl.getPlaybackQuality(), playerImpl.getPlaybackSkipSilence(),
|
}
|
||||||
playerImpl.isPlaying());
|
|
||||||
StateSaver.tryToSave(isChangingConfigurations(), null, outState, this);
|
StateSaver.tryToSave(isChangingConfigurations(), null, outState, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +234,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
if (!isBackPressed) {
|
if (!isBackPressed) {
|
||||||
playerImpl.minimize();
|
playerImpl.minimize();
|
||||||
}
|
}
|
||||||
|
playerState = createPlayerState();
|
||||||
playerImpl.destroy();
|
playerImpl.destroy();
|
||||||
|
|
||||||
isInMultiWindow = false;
|
isInMultiWindow = false;
|
||||||
|
@ -245,6 +245,13 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
// State Saving
|
// State Saving
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
private PlayerState createPlayerState() {
|
||||||
|
return new PlayerState(playerImpl.getPlayQueue(), playerImpl.getRepeatMode(),
|
||||||
|
playerImpl.getPlaybackSpeed(), playerImpl.getPlaybackPitch(),
|
||||||
|
playerImpl.getPlaybackQuality(), playerImpl.getPlaybackSkipSilence(),
|
||||||
|
playerImpl.isPlaying());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSuffix() {
|
public String generateSuffix() {
|
||||||
return "." + UUID.randomUUID().toString() + ".player";
|
return "." + UUID.randomUUID().toString() + ".player";
|
||||||
|
|
|
@ -14,3 +14,6 @@
|
||||||
- Fix time parsing for . format, so NewPipe can be used in Finland
|
- Fix time parsing for . format, so NewPipe can be used in Finland
|
||||||
- Fix subscription count
|
- Fix subscription count
|
||||||
- Add foreground service permission for API 28+ devices #1830
|
- 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