pull/142/head
FongMi 3 years ago
parent 909b52d4f7
commit 42d15f95cb
  1. 20
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  2. 22
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java

@ -100,6 +100,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
private Runnable mR1;
private Runnable mR2;
private Runnable mR3;
private Runnable mR4;
private Clock mClock;
private boolean rotate;
private boolean stop;
@ -161,6 +162,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
mR1 = this::hideControl;
mR2 = this::setTraffic;
mR3 = this::hideInfo;
mR4 = this::stopBack;
mPiP = new PiP();
setRecyclerView();
setVideoView();
@ -858,6 +860,15 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
this.toggleCount = 0;
}
private void startBack() {
App.removeCallbacks(mR4);
PlaybackService.start(mPlayers);
}
private void stopBack() {
PlaybackService.stop();
}
@Override
public void onCastTo() {
}
@ -937,14 +948,14 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode);
if (isInPictureInPictureMode) {
PlaybackService.start(mPlayers);
setSubtitle(10);
hideControl();
startBack();
hideInfo();
hideUI();
} else {
hideInfo();
PlaybackService.stop();
stopBack();
setSubtitle(Setting.getSubtitle());
if (isStop()) finish();
}
@ -972,14 +983,15 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
@Override
protected void onResume() {
super.onResume();
if (Setting.isBackgroundOn()) PlaybackService.stop();
App.removeCallbacks(mR4);
if (Setting.isBackgroundOn()) App.post(mR4, 1000);
mClock.start();
}
@Override
protected void onPause() {
super.onPause();
if (Setting.isBackgroundOn()) PlaybackService.start(mPlayers);
if (Setting.isBackgroundOn() && !isFinishing()) startBack();
mClock.stop();
}

@ -135,6 +135,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
private Runnable mR2;
private Runnable mR3;
private Runnable mR4;
private Runnable mR5;
private Clock mClock;
private String url;
private PiP mPiP;
@ -283,6 +284,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mR2 = this::setTraffic;
mR3 = this::setOrient;
mR4 = this::showEmpty;
mR5 = this::stopBack;
mPiP = new PiP();
setRecyclerView();
setVideoView();
@ -1342,6 +1344,15 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
}
private void startBack() {
App.removeCallbacks(mR5);
PlaybackService.start(mPlayers);
}
private void stopBack() {
PlaybackService.stop();
}
@Override
public void onCastTo() {
checkPlayImg(false);
@ -1448,14 +1459,14 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode);
if (isInPictureInPictureMode) {
PlaybackService.start(mPlayers);
enterFullscreen();
setSubtitle(10);
hideControl();
hideSheet();
startBack();
} else {
stopBack();
exitFullscreen();
PlaybackService.stop();
if (isStop()) finish();
}
}
@ -1485,13 +1496,14 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
@Override
protected void onResume() {
super.onResume();
if (Setting.isBackgroundOn()) PlaybackService.stop();
App.removeCallbacks(mR5);
if (Setting.isBackgroundOn()) App.post(mR5, 1000);
}
@Override
protected void onPause() {
super.onPause();
if (Setting.isBackgroundOn()) PlaybackService.start(mPlayers);
if (Setting.isBackgroundOn() && !isFinishing()) startBack();
}
@Override
@ -1521,8 +1533,8 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mClock.release();
mPlayers.release();
Source.get().stop();
RefreshEvent.history();
PlaybackService.stop();
RefreshEvent.history();
App.removeCallbacks(mR1, mR2, mR3, mR4);
mViewModel.result.removeObserver(mObserveDetail);
mViewModel.player.removeObserver(mObservePlayer);

Loading…
Cancel
Save