mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-05-13 08:20:51 -05:00
video card: playback preview: upd 11
This commit is contained in:
@@ -99,7 +99,6 @@ public final class Video {
|
||||
private long durationMs = -1;
|
||||
private WeakReference<VideoGroup> group; // Memory leak fix. Used to get next page when scrolling.
|
||||
public List<NotificationState> notificationStates;
|
||||
public boolean embedPlayer;
|
||||
|
||||
public Video() {
|
||||
// NOP
|
||||
|
||||
+6
-2
@@ -12,12 +12,12 @@ import com.liskovsoft.mediaserviceinterfaces.NotificationsService;
|
||||
import com.liskovsoft.mediaserviceinterfaces.SignInService;
|
||||
import com.liskovsoft.mediaserviceinterfaces.data.MediaItemMetadata;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.manager.PlayerManager;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.listener.PlayerEventListener;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.models.playback.service.VideoStateService;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.AppDialogPresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.PlaybackPresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.presenters.SearchPresenter;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.views.PlaybackView;
|
||||
import com.liskovsoft.smartyoutubetv2.common.app.views.ViewManager;
|
||||
import com.liskovsoft.smartyoutubetv2.common.exoplayer.selector.FormatItem;
|
||||
import com.liskovsoft.smartyoutubetv2.common.misc.MediaServiceManager;
|
||||
@@ -47,7 +47,7 @@ public abstract class BasePlayerController implements PlayerEventListener {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PlayerManager getPlayer() {
|
||||
public PlaybackView getPlayer() {
|
||||
return mMainController != null ? mMainController.getPlayer() : null;
|
||||
}
|
||||
|
||||
@@ -387,4 +387,8 @@ public abstract class BasePlayerController implements PlayerEventListener {
|
||||
protected PlaybackPresenter getPlaybackPresenter() {
|
||||
return PlaybackPresenter.instance(getContext());
|
||||
}
|
||||
|
||||
protected boolean isEmbedPlayer() {
|
||||
return getPlayer() != null && getPlayer().isEmbed();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -363,14 +363,10 @@ public class AutoFrameRateController extends BasePlayerController implements Aut
|
||||
}
|
||||
|
||||
// NOTE: Avoid detecting shorts by Video.isShorts. Because this is working only in certain places (e.g. Shorts section).
|
||||
return isEmbed() || getPlayer().getDurationMs() <= SHORTS_DURATION_MIN_MS || isSkipShortsPrefs();
|
||||
return isEmbedPlayer() || getPlayer().getDurationMs() <= SHORTS_DURATION_MIN_MS || isSkipShortsPrefs();
|
||||
}
|
||||
|
||||
private boolean isSkipShortsPrefs() {
|
||||
return getPlayerData().isSkipShortsEnabled() && (getPlayer().getVideo().isShorts || getPlayer().getDurationMs() <= SHORTS_DURATION_MAX_MS);
|
||||
}
|
||||
|
||||
private boolean isEmbed() {
|
||||
return getPlayer().getVideo().embedPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@ public class ContentBlockController extends BasePlayerController {
|
||||
boolean stayQuiet = skipDurationMs < 10_000 && PlayerTweaksData.instance(getContext()).isTextureViewEnabled();
|
||||
|
||||
if (!stayQuiet) {
|
||||
if (type == ContentBlockData.ACTION_SKIP_ONLY || getPlayer().isInPIPMode() || Utils.isScreenOff(getContext()) || getPlayer().getVideo().embedPlayer) {
|
||||
if (type == ContentBlockData.ACTION_SKIP_ONLY || getPlayer().isInPIPMode() || Utils.isScreenOff(getContext()) || isEmbedPlayer()) {
|
||||
simpleSkip(skipPosMs);
|
||||
} else if (type == ContentBlockData.ACTION_SKIP_WITH_TOAST) {
|
||||
messageSkip(skipPosMs, skipMessage);
|
||||
|
||||
+1
-1
@@ -229,7 +229,7 @@ public class SuggestionsController extends BasePlayerController {
|
||||
}
|
||||
|
||||
public void loadSuggestions(Video video) {
|
||||
if (video.embedPlayer) {
|
||||
if (isEmbedPlayer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+4
-8
@@ -348,7 +348,7 @@ public class VideoLoaderController extends BasePlayerController implements OnDat
|
||||
}
|
||||
|
||||
if (formatInfo.isUnplayable()) {
|
||||
if (isEmbed()) {
|
||||
if (isEmbedPlayer()) {
|
||||
getPlayer().finish();
|
||||
return;
|
||||
}
|
||||
@@ -465,7 +465,7 @@ public class VideoLoaderController extends BasePlayerController implements OnDat
|
||||
}
|
||||
|
||||
private void runFormatErrorAction(Throwable error) {
|
||||
if (isEmbed()) {
|
||||
if (isEmbedPlayer()) {
|
||||
if (getPlayer() != null) {
|
||||
getPlayer().finish();
|
||||
}
|
||||
@@ -496,7 +496,7 @@ public class VideoLoaderController extends BasePlayerController implements OnDat
|
||||
|
||||
private void runEngineErrorAction(int type, int rendererIndex, Throwable error) {
|
||||
// Hide begin errors in embed mode (e.g. wrong date/time: unable to connect to...)
|
||||
if (isEmbed() && getPlayer() != null && getPlayer().getPositionMs() == 0) {
|
||||
if (isEmbedPlayer() && getPlayer() != null && getPlayer().getPositionMs() == 0) {
|
||||
getPlayer().finish();
|
||||
return;
|
||||
}
|
||||
@@ -680,7 +680,7 @@ public class VideoLoaderController extends BasePlayerController implements OnDat
|
||||
return;
|
||||
}
|
||||
|
||||
if (video.embedPlayer) {
|
||||
if (isEmbedPlayer()) {
|
||||
playbackMode = PlayerConstants.PLAYBACK_MODE_CLOSE;
|
||||
}
|
||||
|
||||
@@ -966,8 +966,4 @@ public class VideoLoaderController extends BasePlayerController implements OnDat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmbed() {
|
||||
return mLastVideo != null && mLastVideo.embedPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-10
@@ -52,10 +52,8 @@ public class VideoStateController extends BasePlayerController {
|
||||
// In case video opened from phone and other stuff.
|
||||
removeFromHistoryIfNeeded();
|
||||
saveState();
|
||||
} else if (isEmbed()) { // switching from embed to normal player
|
||||
// Save state of the previous video.
|
||||
// In case video opened from phone and other stuff.
|
||||
saveState();
|
||||
} else if (isEmbedPlayer()) { // switching from embed to normal player
|
||||
savePosition();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,14 +667,10 @@ public class VideoStateController extends BasePlayerController {
|
||||
}
|
||||
|
||||
private boolean isMutedEmbed() {
|
||||
return isEmbed() && getPlayer() != null && Helpers.floatEquals(getPlayer().getVolume(), 0);
|
||||
return isEmbedPlayer() && getPlayer() != null && Helpers.floatEquals(getPlayer().getVolume(), 0);
|
||||
}
|
||||
|
||||
private boolean isBeginEmbed() {
|
||||
return isEmbed() && System.currentTimeMillis() - mNewVideoTimeMs <= EMBED_THRESHOLD_MS;
|
||||
}
|
||||
|
||||
private boolean isEmbed() {
|
||||
return getVideo() != null && getVideo().embedPlayer;
|
||||
return isEmbedPlayer() && System.currentTimeMillis() - mNewVideoTimeMs <= EMBED_THRESHOLD_MS;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -12,4 +12,5 @@ public interface PlayerManager extends PlayerEngine, PlayerUI {
|
||||
void showBackground(String url);
|
||||
void showBackgroundColor(int colorResId);
|
||||
void resetPlayerState();
|
||||
boolean isEmbed();
|
||||
}
|
||||
|
||||
+5
@@ -1589,6 +1589,11 @@ public class PlaybackFragment extends SeekModePlaybackFragment implements Playba
|
||||
setSeekPreviewTitle(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmbed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* PIP mode fix
|
||||
*/
|
||||
|
||||
+5
-3
@@ -275,6 +275,11 @@ public class EmbedPlayerView extends PlayerView implements PlaybackView {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmbed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openDash(InputStream dashManifest) {
|
||||
mExoPlayerController.openDash(dashManifest);
|
||||
@@ -494,8 +499,6 @@ public class EmbedPlayerView extends PlayerView implements PlaybackView {
|
||||
}
|
||||
|
||||
public void openVideo(@NonNull Video video) {
|
||||
video.embedPlayer = true;
|
||||
|
||||
if (mPlaybackPresenter == null) {
|
||||
mPlaybackPresenter = PlaybackPresenter.instance(getContext());
|
||||
}
|
||||
@@ -562,7 +565,6 @@ public class EmbedPlayerView extends PlayerView implements PlaybackView {
|
||||
setPlayer(null);
|
||||
hideView();
|
||||
if (mVideo != null) {
|
||||
mVideo.embedPlayer = false;
|
||||
BasePresenter<?> presenter = ViewManager.instance(getContext()).getCurrentPresenter();
|
||||
if (presenter != null) {
|
||||
presenter.syncItem(mVideo);
|
||||
|
||||
Reference in New Issue
Block a user