mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-01-25 16:10:20 -06:00
pip update
This commit is contained in:
@@ -6,9 +6,6 @@ import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video.State;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.PlayerEventListenerHelper;
|
||||
import com.liskovsoft.smartyoutubetv2.common.autoframerate.FormatItem;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StateUpdater extends PlayerEventListenerHelper {
|
||||
private boolean mIsPlaying;
|
||||
private int mRepeatMode = 0;
|
||||
@@ -18,6 +15,11 @@ public class StateUpdater extends PlayerEventListenerHelper {
|
||||
@Override
|
||||
public void openVideo(Video item) {
|
||||
mIsPlaying = true; // video just added
|
||||
|
||||
// Ensure that we aren't running on presenter init stage
|
||||
if (mController != null) {
|
||||
saveState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,11 +52,21 @@ public class PlaybackPresenter implements Presenter<PlaybackView> {
|
||||
public void openVideo(Object parentView, Video item) {
|
||||
mMainPlayerEventBridge.setParentView(parentView);
|
||||
mMainPlayerEventBridge.openVideo(item);
|
||||
mViewManager.startView(PlaybackView.class);
|
||||
|
||||
focusView();
|
||||
}
|
||||
|
||||
public void openVideo(String videoId) {
|
||||
mMainPlayerEventBridge.openVideo(Video.from(videoId));
|
||||
|
||||
focusView();
|
||||
}
|
||||
|
||||
private void focusView() {
|
||||
if (mView != null && mView.getController().isPIPEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mViewManager.startView(PlaybackView.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,13 +154,12 @@ public class PlaybackFragment extends VideoSupportFragment implements PlaybackVi
|
||||
}
|
||||
|
||||
public void restartPlayer() {
|
||||
boolean engineBlocked = isEngineBlocked();
|
||||
blockEngine(false);
|
||||
|
||||
releasePlayer();
|
||||
initializePlayer();
|
||||
|
||||
blockEngine(engineBlocked);
|
||||
if (mPlayer != null) {
|
||||
mEventListener.onEngineReleased();
|
||||
}
|
||||
destroyPlayerObjects();
|
||||
createPlayerObjects();
|
||||
mEventListener.onEngineInitialized();
|
||||
}
|
||||
|
||||
private void releasePlayer() {
|
||||
@@ -172,13 +171,7 @@ public class PlaybackFragment extends VideoSupportFragment implements PlaybackVi
|
||||
if (mPlayer != null) {
|
||||
Log.d(TAG, "releasePlayer: Start releasing player engine...");
|
||||
mEventListener.onEngineReleased();
|
||||
mPlayer.release();
|
||||
mPlayer = null;
|
||||
mTrackSelector = null;
|
||||
mPlayerGlue = null;
|
||||
mPlayerAdapter = null;
|
||||
mPlaylistActionListener = null;
|
||||
mExoPlayerController = null;
|
||||
destroyPlayerObjects();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +181,24 @@ public class PlaybackFragment extends VideoSupportFragment implements PlaybackVi
|
||||
return;
|
||||
}
|
||||
|
||||
createPlayerObjects();
|
||||
|
||||
mEventListener.onEngineInitialized();
|
||||
}
|
||||
|
||||
private void destroyPlayerObjects() {
|
||||
if (mPlayer != null) {
|
||||
mPlayer.release();
|
||||
}
|
||||
mPlayer = null;
|
||||
mTrackSelector = null;
|
||||
mPlayerGlue = null;
|
||||
mPlayerAdapter = null;
|
||||
mPlaylistActionListener = null;
|
||||
mExoPlayerController = null;
|
||||
}
|
||||
|
||||
private void createPlayerObjects() {
|
||||
TrackSelection.Factory videoTrackSelectionFactory =
|
||||
new AdaptiveTrackSelection.Factory();
|
||||
mTrackSelector = new RestoreTrackSelector(videoTrackSelectionFactory);
|
||||
@@ -212,8 +223,6 @@ public class PlaybackFragment extends VideoSupportFragment implements PlaybackVi
|
||||
|
||||
mRowsSupportFragment = (RowsSupportFragment) getChildFragmentManager().findFragmentById(
|
||||
R.id.playback_controls_dock);
|
||||
|
||||
mEventListener.onEngineInitialized();
|
||||
}
|
||||
|
||||
private ArrayObjectAdapter initializeSuggestedVideosRow() {
|
||||
|
||||
Reference in New Issue
Block a user