More fixes with opening VideoDetailFragment
This commit is contained in:
parent
bb882ada2c
commit
2a2c82e73b
13 changed files with 87 additions and 170 deletions
|
@ -685,7 +685,7 @@ public class RouterActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
if (choice.playerChoice.equals(videoPlayerKey)) {
|
||||
NavigationHelper.playOnMainPlayer(this, playQueue);
|
||||
NavigationHelper.playOnMainPlayer(this, playQueue, false);
|
||||
} else if (choice.playerChoice.equals(backgroundPlayerKey)) {
|
||||
NavigationHelper.playOnBackgroundPlayer(this, playQueue, true);
|
||||
} else if (choice.playerChoice.equals(popupPlayerKey)) {
|
||||
|
|
|
@ -1097,7 +1097,7 @@ public final class VideoDetailFragment
|
|||
|
||||
private void openMainPlayer() {
|
||||
if (playerService == null) {
|
||||
PlayerHolder.startService(App.getApp(), true, this);
|
||||
PlayerHolder.startService(App.getApp(), autoPlayEnabled, this);
|
||||
return;
|
||||
}
|
||||
if (currentInfo == null) {
|
||||
|
@ -1112,7 +1112,7 @@ public final class VideoDetailFragment
|
|||
addVideoPlayerView();
|
||||
|
||||
final Intent playerIntent = NavigationHelper
|
||||
.getPlayerIntent(requireContext(), MainPlayer.class, queue, null, true);
|
||||
.getPlayerIntent(requireContext(), MainPlayer.class, queue, true, autoPlayEnabled);
|
||||
activity.startService(playerIntent);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,8 @@ package org.schabi.newpipe.player;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.util.NavigationHelper;
|
||||
import org.schabi.newpipe.util.PermissionHelper;
|
||||
|
||||
public final class BackgroundPlayerActivity extends ServicePlayerActivity {
|
||||
|
||||
|
@ -46,31 +43,6 @@ public final class BackgroundPlayerActivity extends ServicePlayerActivity {
|
|||
return R.menu.menu_play_queue_bg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPlayerOptionSelected(final MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_switch_popup) {
|
||||
|
||||
if (!PermissionHelper.isPopupEnabled(this)) {
|
||||
PermissionHelper.showPopupEnablementToast(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnPopupPlayer(
|
||||
getApplicationContext(), player.playQueue, this.player.isPlaying());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getItemId() == R.id.action_switch_background) {
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnBackgroundPlayer(
|
||||
getApplicationContext(), player.playQueue, this.player.isPlaying());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupMenu(final Menu menu) {
|
||||
if (player == null) {
|
||||
|
|
|
@ -125,7 +125,7 @@ public abstract class BasePlayer implements
|
|||
@NonNull
|
||||
public static final String RESUME_PLAYBACK = "resume_playback";
|
||||
@NonNull
|
||||
public static final String START_PAUSED = "start_paused";
|
||||
public static final String PLAY_WHEN_READY = "play_when_ready";
|
||||
@NonNull
|
||||
public static final String SELECT_ON_APPEND = "select_on_append";
|
||||
@NonNull
|
||||
|
@ -224,7 +224,7 @@ public abstract class BasePlayer implements
|
|||
this.dataSource = new PlayerDataSource(context, userAgent, bandwidthMeter);
|
||||
|
||||
final TrackSelection.Factory trackSelectionFactory = PlayerHelper
|
||||
.getQualitySelector(context);
|
||||
.getQualitySelector();
|
||||
this.trackSelector = new CustomTrackSelector(context, trackSelectionFactory);
|
||||
|
||||
this.loadControl = new LoadController();
|
||||
|
@ -302,6 +302,7 @@ public abstract class BasePlayer implements
|
|||
final boolean samePlayQueue = playQueue != null && playQueue.equals(queue);
|
||||
|
||||
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
|
||||
final boolean playWhenReady = intent.getBooleanExtra(PLAY_WHEN_READY, true);
|
||||
final boolean isMuted = intent
|
||||
.getBooleanExtra(IS_MUTED, simpleExoPlayer != null && isMuted());
|
||||
|
||||
|
@ -327,16 +328,20 @@ public abstract class BasePlayer implements
|
|||
simpleExoPlayer.retry();
|
||||
}
|
||||
simpleExoPlayer.seekTo(playQueue.getIndex(), queue.getItem().getRecoveryPosition());
|
||||
return;
|
||||
simpleExoPlayer.setPlayWhenReady(playWhenReady);
|
||||
|
||||
} else if (samePlayQueue && !playQueue.isDisposed() && simpleExoPlayer != null) {
|
||||
} else if (simpleExoPlayer != null
|
||||
&& samePlayQueue
|
||||
&& playQueue != null
|
||||
&& !playQueue.isDisposed()) {
|
||||
// Do not re-init the same PlayQueue. Save time
|
||||
// Player can have state = IDLE when playback is stopped or failed
|
||||
// and we should retry() in this case
|
||||
if (simpleExoPlayer.getPlaybackState() == Player.STATE_IDLE) {
|
||||
simpleExoPlayer.retry();
|
||||
}
|
||||
return;
|
||||
simpleExoPlayer.setPlayWhenReady(playWhenReady);
|
||||
|
||||
} else if (intent.getBooleanExtra(RESUME_PLAYBACK, false)
|
||||
&& isPlaybackResumeEnabled()
|
||||
&& !samePlayQueue) {
|
||||
|
@ -351,7 +356,7 @@ public abstract class BasePlayer implements
|
|||
state -> {
|
||||
queue.setRecovery(queue.getIndex(), state.getProgressTime());
|
||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch,
|
||||
playbackSkipSilence, true, isMuted);
|
||||
playbackSkipSilence, playWhenReady, isMuted);
|
||||
},
|
||||
error -> {
|
||||
if (DEBUG) {
|
||||
|
@ -359,24 +364,22 @@ public abstract class BasePlayer implements
|
|||
}
|
||||
// In case any error we can start playback without history
|
||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch,
|
||||
playbackSkipSilence, true, isMuted);
|
||||
playbackSkipSilence, playWhenReady, isMuted);
|
||||
},
|
||||
() -> {
|
||||
// Completed but not found in history
|
||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch,
|
||||
playbackSkipSilence, true, isMuted);
|
||||
playbackSkipSilence, playWhenReady, isMuted);
|
||||
}
|
||||
);
|
||||
databaseUpdateReactor.add(stateLoader);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Good to go...
|
||||
// In a case of equal PlayQueues we can re-init old one but only when it is disposed
|
||||
initPlayback(samePlayQueue ? playQueue : queue, repeatMode,
|
||||
playbackSpeed, playbackPitch, playbackSkipSilence,
|
||||
!intent.getBooleanExtra(START_PAUSED, false),
|
||||
isMuted);
|
||||
initPlayback(samePlayQueue ? playQueue : queue, repeatMode, playbackSpeed,
|
||||
playbackPitch, playbackSkipSilence, playWhenReady, isMuted);
|
||||
}
|
||||
}
|
||||
|
||||
private PlaybackParameters retrievePlaybackParametersFromPreferences() {
|
||||
|
|
|
@ -240,7 +240,7 @@ public final class MainPlayer extends Service {
|
|||
}
|
||||
|
||||
public void removeViewFromParent() {
|
||||
if (getView().getParent() != null) {
|
||||
if (getView() != null && getView().getParent() != null) {
|
||||
if (playerImpl.getParentActivity() != null) {
|
||||
// This means view was added to fragment
|
||||
final ViewGroup parent = (ViewGroup) getView().getParent();
|
||||
|
|
|
@ -27,9 +27,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||
import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
|
||||
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
||||
|
@ -42,9 +40,9 @@ import org.schabi.newpipe.player.playqueue.PlayQueueItem;
|
|||
import org.schabi.newpipe.player.playqueue.PlayQueueItemBuilder;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueItemHolder;
|
||||
import org.schabi.newpipe.player.playqueue.PlayQueueItemTouchCallback;
|
||||
import org.schabi.newpipe.util.Constants;
|
||||
import org.schabi.newpipe.util.Localization;
|
||||
import org.schabi.newpipe.util.NavigationHelper;
|
||||
import org.schabi.newpipe.util.PermissionHelper;
|
||||
import org.schabi.newpipe.util.ThemeHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -113,9 +111,8 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
|
||||
public abstract int getPlayerOptionMenuResource();
|
||||
|
||||
public abstract boolean onPlayerOptionSelected(MenuItem item);
|
||||
|
||||
public abstract void setupMenu(Menu m);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Activity Lifecycle
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -187,12 +184,22 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
return true;
|
||||
case R.id.action_switch_main:
|
||||
this.player.setRecovery();
|
||||
getApplicationContext().startActivity(
|
||||
getSwitchIntent(MainActivity.class, MainPlayer.PlayerType.VIDEO)
|
||||
.putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying()));
|
||||
NavigationHelper.playOnMainPlayer(this, player.getPlayQueue(), true);
|
||||
return true;
|
||||
case R.id.action_switch_popup:
|
||||
if (PermissionHelper.isPopupEnabled(this)) {
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnPopupPlayer(this, player.playQueue, true);
|
||||
} else {
|
||||
PermissionHelper.showPopupEnablementToast(this);
|
||||
}
|
||||
return true;
|
||||
case R.id.action_switch_background:
|
||||
this.player.setRecovery();
|
||||
NavigationHelper.playOnBackgroundPlayer(this, player.playQueue, true);
|
||||
return true;
|
||||
}
|
||||
return onPlayerOptionSelected(item) || super.onOptionsItemSelected(item);
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -201,24 +208,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
unbind();
|
||||
}
|
||||
|
||||
protected Intent getSwitchIntent(final Class clazz, final MainPlayer.PlayerType playerType) {
|
||||
return NavigationHelper.getPlayerIntent(getApplicationContext(), clazz,
|
||||
this.player.getPlayQueue(), this.player.getRepeatMode(),
|
||||
this.player.getPlaybackSpeed(), this.player.getPlaybackPitch(),
|
||||
this.player.getPlaybackSkipSilence(),
|
||||
null,
|
||||
true,
|
||||
!this.player.isPlaying(),
|
||||
this.player.isMuted())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(Constants.KEY_LINK_TYPE, StreamingService.LinkType.STREAM)
|
||||
.putExtra(Constants.KEY_URL, this.player.getVideoUrl())
|
||||
.putExtra(Constants.KEY_TITLE, this.player.getVideoTitle())
|
||||
.putExtra(Constants.KEY_SERVICE_ID,
|
||||
this.player.getCurrentMetadata().getMetadata().getServiceId())
|
||||
.putExtra(VideoPlayer.PLAYER_TYPE, playerType);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Service Connection
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -368,8 +357,8 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||
Menu.NONE, R.string.play_queue_stream_detail);
|
||||
detail.setOnMenuItemClickListener(menuItem -> {
|
||||
// playQueue is null since we don't want any queue change
|
||||
NavigationHelper.openVideoDetail(
|
||||
this, item.getServiceId(), item.getUrl(), item.getTitle(), null);
|
||||
NavigationHelper.openVideoDetail(this, item.getServiceId(), item.getUrl(),
|
||||
item.getTitle(), null, false);
|
||||
return true;
|
||||
});
|
||||
|
||||
|
|
|
@ -76,9 +76,7 @@ import com.google.android.exoplayer2.ui.SubtitleView;
|
|||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||
import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
|
||||
|
@ -97,7 +95,6 @@ import org.schabi.newpipe.player.resolver.AudioPlaybackResolver;
|
|||
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
||||
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
||||
import org.schabi.newpipe.util.AnimationUtils;
|
||||
import org.schabi.newpipe.util.Constants;
|
||||
import org.schabi.newpipe.util.DeviceUtils;
|
||||
import org.schabi.newpipe.util.KoreUtil;
|
||||
import org.schabi.newpipe.util.ListHelper;
|
||||
|
@ -260,7 +257,12 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||
onQueueClosed();
|
||||
// Android TV: without it focus will frame the whole player
|
||||
playPauseButton.requestFocus();
|
||||
|
||||
if (simpleExoPlayer.getPlayWhenReady()) {
|
||||
onPlay();
|
||||
} else {
|
||||
onPause();
|
||||
}
|
||||
}
|
||||
NavigationHelper.sendPlayerStartedEvent(service);
|
||||
}
|
||||
|
@ -756,40 +758,6 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||
setupScreenRotationButton();
|
||||
}
|
||||
|
||||
public void switchFromPopupToMain() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "switchFromPopupToMain() called");
|
||||
}
|
||||
if (!popupPlayerSelected() || simpleExoPlayer == null || getCurrentMetadata() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setRecovery();
|
||||
service.removeViewFromParent();
|
||||
final Intent intent = NavigationHelper.getPlayerIntent(
|
||||
service,
|
||||
MainActivity.class,
|
||||
this.getPlayQueue(),
|
||||
this.getRepeatMode(),
|
||||
this.getPlaybackSpeed(),
|
||||
this.getPlaybackPitch(),
|
||||
this.getPlaybackSkipSilence(),
|
||||
null,
|
||||
true,
|
||||
!isPlaying(),
|
||||
isMuted()
|
||||
);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Constants.KEY_SERVICE_ID,
|
||||
getCurrentMetadata().getMetadata().getServiceId());
|
||||
intent.putExtra(Constants.KEY_LINK_TYPE, StreamingService.LinkType.STREAM);
|
||||
intent.putExtra(Constants.KEY_URL, getVideoUrl());
|
||||
intent.putExtra(Constants.KEY_TITLE, getVideoTitle());
|
||||
intent.putExtra(VideoDetailFragment.KEY_SWITCHING_PLAYERS, true);
|
||||
service.onDestroy();
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
super.onClick(v);
|
||||
|
@ -817,7 +785,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||
} else if (v.getId() == openInBrowser.getId()) {
|
||||
onOpenInBrowserClicked();
|
||||
} else if (v.getId() == fullscreenButton.getId()) {
|
||||
switchFromPopupToMain();
|
||||
setRecovery();
|
||||
NavigationHelper.playOnMainPlayer(context, getPlayQueue(), true);
|
||||
return;
|
||||
} else if (v.getId() == screenRotationButton.getId()) {
|
||||
// Only if it's not a vertical video or vertical video but in landscape with locked
|
||||
// orientation a screen orientation can be changed automatically
|
||||
|
|
|
@ -63,7 +63,7 @@ abstract class BasePlayerGestureListener(
|
|||
private var isMovingInPopup = false
|
||||
private var isResizing = false
|
||||
|
||||
private val tossFlingVelocity = PlayerHelper.getTossFlingVelocity(service)
|
||||
private val tossFlingVelocity = PlayerHelper.getTossFlingVelocity()
|
||||
|
||||
// [popup] initial coordinates and distance between fingers
|
||||
private var initPointerDistance = -1.0
|
||||
|
@ -104,9 +104,6 @@ abstract class BasePlayerGestureListener(
|
|||
}
|
||||
|
||||
private fun onTouchInPopup(v: View, event: MotionEvent): Boolean {
|
||||
if (playerImpl == null) {
|
||||
return false
|
||||
}
|
||||
playerImpl.gestureDetector.onTouchEvent(event)
|
||||
if (event.pointerCount == 2 && !isMovingInPopup && !isResizing) {
|
||||
if (DEBUG) {
|
||||
|
|
|
@ -164,7 +164,7 @@ public class AudioReactor implements AudioManager.OnAudioFocusChangeListener, An
|
|||
|
||||
@Override
|
||||
public void onAudioSessionId(final EventTime eventTime, final int audioSessionId) {
|
||||
if (!PlayerHelper.isUsingDSP(context)) {
|
||||
if (!PlayerHelper.isUsingDSP()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ public final class PlayerHelper {
|
|||
return 60000;
|
||||
}
|
||||
|
||||
public static TrackSelection.Factory getQualitySelector(@NonNull final Context context) {
|
||||
public static TrackSelection.Factory getQualitySelector() {
|
||||
return new AdaptiveTrackSelection.Factory(
|
||||
1000,
|
||||
AdaptiveTrackSelection.DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS,
|
||||
|
@ -303,11 +303,11 @@ public final class PlayerHelper {
|
|||
AdaptiveTrackSelection.DEFAULT_BANDWIDTH_FRACTION);
|
||||
}
|
||||
|
||||
public static boolean isUsingDSP(@NonNull final Context context) {
|
||||
public static boolean isUsingDSP() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getTossFlingVelocity(@NonNull final Context context) {
|
||||
public static int getTossFlingVelocity() {
|
||||
return 2500;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,13 @@ public final class PlayerHolder {
|
|||
return player.getPlayerType();
|
||||
}
|
||||
|
||||
public static boolean isPlaying() {
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return player.isPlaying();
|
||||
}
|
||||
|
||||
public static void setListener(final PlayerServiceExtendedEventListener newListener) {
|
||||
listener = newListener;
|
||||
// Force reload data from service
|
||||
|
|
|
@ -64,6 +64,20 @@ public class PlayQueueItem implements Serializable {
|
|||
this.recoveryPosition = RECOVERY_UNSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o instanceof PlayQueueItem) {
|
||||
return url.equals(((PlayQueueItem) o).url);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return url.hashCode();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getTitle() {
|
||||
return title;
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
|||
import org.schabi.newpipe.fragments.MainFragment;
|
||||
import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
|
||||
import org.schabi.newpipe.fragments.list.channel.ChannelFragment;
|
||||
import org.schabi.newpipe.fragments.list.comments.CommentsFragment;
|
||||
import org.schabi.newpipe.fragments.list.kiosk.KioskFragment;
|
||||
import org.schabi.newpipe.fragments.list.playlist.PlaylistFragment;
|
||||
import org.schabi.newpipe.fragments.list.search.SearchFragment;
|
||||
|
@ -73,7 +72,6 @@ public final class NavigationHelper {
|
|||
public static <T> Intent getPlayerIntent(@NonNull final Context context,
|
||||
@NonNull final Class<T> targetClazz,
|
||||
@Nullable final PlayQueue playQueue,
|
||||
@Nullable final String quality,
|
||||
final boolean resumePlayback) {
|
||||
final Intent intent = new Intent(context, targetClazz);
|
||||
|
||||
|
@ -83,9 +81,6 @@ public final class NavigationHelper {
|
|||
intent.putExtra(VideoPlayer.PLAY_QUEUE_KEY, cacheKey);
|
||||
}
|
||||
}
|
||||
if (quality != null) {
|
||||
intent.putExtra(VideoPlayer.PLAYBACK_QUALITY, quality);
|
||||
}
|
||||
intent.putExtra(VideoPlayer.RESUME_PLAYBACK, resumePlayback);
|
||||
intent.putExtra(VideoPlayer.PLAYER_TYPE, VideoPlayer.PLAYER_TYPE_VIDEO);
|
||||
|
||||
|
@ -96,8 +91,10 @@ public final class NavigationHelper {
|
|||
public static <T> Intent getPlayerIntent(@NonNull final Context context,
|
||||
@NonNull final Class<T> targetClazz,
|
||||
@Nullable final PlayQueue playQueue,
|
||||
final boolean resumePlayback) {
|
||||
return getPlayerIntent(context, targetClazz, playQueue, null, resumePlayback);
|
||||
final boolean resumePlayback,
|
||||
final boolean playWhenReady) {
|
||||
return getPlayerIntent(context, targetClazz, playQueue, resumePlayback)
|
||||
.putExtra(BasePlayer.PLAY_WHEN_READY, playWhenReady);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -111,24 +108,6 @@ public final class NavigationHelper {
|
|||
.putExtra(BasePlayer.SELECT_ON_APPEND, selectOnAppend);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static <T> Intent getPlayerIntent(@NonNull final Context context,
|
||||
@NonNull final Class<T> targetClazz,
|
||||
@Nullable final PlayQueue playQueue,
|
||||
final int repeatMode,
|
||||
final float playbackSpeed,
|
||||
final float playbackPitch,
|
||||
final boolean playbackSkipSilence,
|
||||
@Nullable final String playbackQuality,
|
||||
final boolean resumePlayback,
|
||||
final boolean startPaused,
|
||||
final boolean isMuted) {
|
||||
return getPlayerIntent(context, targetClazz, playQueue, playbackQuality, resumePlayback)
|
||||
.putExtra(BasePlayer.REPEAT_MODE, repeatMode)
|
||||
.putExtra(BasePlayer.START_PAUSED, startPaused)
|
||||
.putExtra(BasePlayer.IS_MUTED, isMuted);
|
||||
}
|
||||
|
||||
public static void playOnMainPlayer(final AppCompatActivity activity,
|
||||
@NonNull final PlayQueue playQueue) {
|
||||
final PlayQueueItem item = playQueue.getItem();
|
||||
|
@ -138,10 +117,12 @@ public final class NavigationHelper {
|
|||
}
|
||||
|
||||
public static void playOnMainPlayer(final Context context,
|
||||
@NonNull final PlayQueue playQueue) {
|
||||
@NonNull final PlayQueue playQueue,
|
||||
final boolean switchingPlayers) {
|
||||
final PlayQueueItem item = playQueue.getItem();
|
||||
assert item != null;
|
||||
openVideoDetail(context, item.getServiceId(), item.getUrl(), item.getTitle(), playQueue);
|
||||
openVideoDetail(context,
|
||||
item.getServiceId(), item.getUrl(), item.getTitle(), playQueue, switchingPlayers);
|
||||
}
|
||||
|
||||
public static void playOnPopupPlayer(final Context context,
|
||||
|
@ -370,7 +351,7 @@ public final class NavigationHelper {
|
|||
autoPlay = PlayerHelper.isAutoplayAllowedByUser(context);
|
||||
} else if (switchingPlayers) {
|
||||
// switching player to main player
|
||||
autoPlay = true;
|
||||
autoPlay = PlayerHolder.isPlaying(); // keep play/pause state
|
||||
} else if (playerType == MainPlayer.PlayerType.VIDEO) {
|
||||
// opening new stream while already playing in main player
|
||||
autoPlay = PlayerHelper.isAutoplayAllowedByUser(context);
|
||||
|
@ -416,16 +397,6 @@ public final class NavigationHelper {
|
|||
.commit();
|
||||
}
|
||||
|
||||
public static void openCommentsFragment(final FragmentManager fragmentManager,
|
||||
final int serviceId, final String url,
|
||||
@NonNull final String name) {
|
||||
fragmentManager.beginTransaction()
|
||||
.setCustomAnimations(R.anim.switch_service_in, R.anim.switch_service_out)
|
||||
.replace(R.id.fragment_holder, CommentsFragment.getInstance(serviceId, url, name))
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public static void openPlaylistFragment(final FragmentManager fragmentManager,
|
||||
final int serviceId, final String url,
|
||||
@NonNull final String name) {
|
||||
|
@ -506,23 +477,17 @@ public final class NavigationHelper {
|
|||
context.startActivity(mIntent);
|
||||
}
|
||||
|
||||
public static void openChannel(final Context context, final int serviceId,
|
||||
final String url, @NonNull final String name) {
|
||||
final Intent openIntent = getOpenIntent(context, url, serviceId,
|
||||
StreamingService.LinkType.CHANNEL);
|
||||
openIntent.putExtra(Constants.KEY_TITLE, name);
|
||||
context.startActivity(openIntent);
|
||||
}
|
||||
|
||||
public static void openVideoDetail(final Context context,
|
||||
final int serviceId,
|
||||
final String url,
|
||||
@NonNull final String title,
|
||||
@Nullable final PlayQueue playQueue) {
|
||||
@Nullable final PlayQueue playQueue,
|
||||
final boolean switchingPlayers) {
|
||||
|
||||
final Intent intent = getOpenIntent(context, url, serviceId,
|
||||
StreamingService.LinkType.STREAM);
|
||||
intent.putExtra(Constants.KEY_TITLE, title);
|
||||
intent.putExtra(VideoDetailFragment.KEY_SWITCHING_PLAYERS, switchingPlayers);
|
||||
|
||||
if (playQueue != null) {
|
||||
final String cacheKey = SerializedCache.getInstance().put(playQueue, PlayQueue.class);
|
||||
|
|
Loading…
Add table
Reference in a new issue