Skip to content

[pull] master from yuliskov:master #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ private void applyScreenOffTimeout(int buttonState) {
}

private void prepareScreenOff() {
if (getPlayer() == null) {
if (getPlayer() == null || getActivity() == null) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void onPlayEnd() {
postPlay(false);
break;
case PlayerConstants.PLAYBACK_MODE_ONE:
postStartPlaying(getPlayer().getVideo(), true);
postStartPlaying(getVideo(), true);
break;
}
}
Expand Down Expand Up @@ -310,7 +310,7 @@ private void processCommand(Command command) {
break;
case Command.TYPE_UPDATE_PLAYLIST:
if (getPlayer() != null && mConnected) {
Video video = getPlayer().getVideo();
Video video = getVideo();
// Ensure that remote playlist already playing
if (video != null && video.remotePlaylistId != null) {
video.remotePlaylistId = command.getPlaylistId();
Expand Down Expand Up @@ -372,7 +372,7 @@ private void processCommand(Command command) {
case Command.TYPE_GET_STATE:
if (getPlayer() != null) {
getViewManager().moveAppToForeground();
postStartPlaying(getPlayer().getVideo(), getPlayer().isPlaying());
postStartPlaying(getVideo(), getPlayer().isPlaying());
} else {
postStartPlaying(null, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class VideoLoaderController extends BasePlayerController implements OnDat
private final Runnable mLoadNext = this::loadNext;
private final Runnable mMetadataSync = () -> {
if (getPlayer() != null) {
waitMetadataSync(getPlayer().getVideo(), false);
waitMetadataSync(getVideo(), false);
}
};
private final Runnable mRestartEngine = () -> {
Expand Down Expand Up @@ -213,10 +213,10 @@ public void loadNext() {
//getVideo() = null; // in case next video is the same as previous

if (next != null) {
forceSectionPlaylistIfNeeded(getPlayer().getVideo(), next);
forceSectionPlaylistIfNeeded(getVideo(), next);
openVideoInt(next);
} else {
waitMetadataSync(getPlayer().getVideo(), true);
waitMetadataSync(getVideo(), true);
}

if (getPlayerTweaksData().isPlayerUiOnNextEnabled()) {
Expand Down Expand Up @@ -284,7 +284,7 @@ private void checkSleepTimer() {
* Force load and play!
*/
private void loadVideo(Video item) {
if (item != null) {
if (getPlayer() != null && item != null) {
mPlaylist.setCurrent(item);
getPlayer().setVideo(item);
getPlayer().resetPlayerState();
Expand Down Expand Up @@ -678,9 +678,9 @@ private List<String> applyFix(List<String> urlList) {
}

private void applyPlaybackMode(int playbackMode) {
Video video = getPlayer().getVideo();
Video video = getVideo();
// Fix simultaneous videos loading (e.g. when playback ends and user opens new video)
if (isActionsRunning() || video == null) {
if (video == null || isActionsRunning()) {
return;
}

Expand Down Expand Up @@ -759,7 +759,7 @@ private void applyPlaybackMode(int playbackMode) {
}

private void restartPlaylist() {
Video currentVideo = getPlayer().getVideo();
Video currentVideo = getVideo();
VideoGroup group = currentVideo.getGroup(); // Get the VideoGroup (playlist)

if (group != null && !group.isEmpty()) {
Expand Down Expand Up @@ -952,7 +952,7 @@ private boolean isFasterDataSourceEnabled() {
private int getPlaybackMode() {
int playbackMode = getPlayerData().getPlaybackMode();

Video video = getPlayer().getVideo();
Video video = getVideo();
if (video != null && video.finishOnEnded) {
playbackMode = PlayerConstants.PLAYBACK_MODE_CLOSE;
} else if (video != null && video.belongsToShortsGroup() && getPlayerTweaksData().isLoopShortsEnabled()) {
Expand Down