2727import com .google .android .exoplayer2 .PlaybackParameters ;
2828import com .google .android .exoplayer2 .Player ;
2929
30- import org .schabi .newpipe .MainActivity ;
3130import org .schabi .newpipe .R ;
32- import org .schabi .newpipe .extractor .StreamingService ;
3331import org .schabi .newpipe .extractor .stream .StreamInfo ;
3432import org .schabi .newpipe .fragments .OnScrollBelowItemsListener ;
3533import org .schabi .newpipe .local .dialog .PlaylistAppendDialog ;
4240import org .schabi .newpipe .player .playqueue .PlayQueueItemBuilder ;
4341import org .schabi .newpipe .player .playqueue .PlayQueueItemHolder ;
4442import org .schabi .newpipe .player .playqueue .PlayQueueItemTouchCallback ;
45- import org .schabi .newpipe .util .Constants ;
4643import org .schabi .newpipe .util .Localization ;
4744import org .schabi .newpipe .util .NavigationHelper ;
45+ import org .schabi .newpipe .util .PermissionHelper ;
4846import org .schabi .newpipe .util .ThemeHelper ;
4947
5048import java .util .Collections ;
@@ -113,9 +111,8 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
113111
114112 public abstract int getPlayerOptionMenuResource ();
115113
116- public abstract boolean onPlayerOptionSelected (MenuItem item );
117-
118114 public abstract void setupMenu (Menu m );
115+
119116 ////////////////////////////////////////////////////////////////////////////
120117 // Activity Lifecycle
121118 ////////////////////////////////////////////////////////////////////////////
@@ -187,12 +184,22 @@ public boolean onOptionsItemSelected(final MenuItem item) {
187184 return true ;
188185 case R .id .action_switch_main :
189186 this .player .setRecovery ();
190- getApplicationContext ().startActivity (
191- getSwitchIntent (MainActivity .class , MainPlayer .PlayerType .VIDEO )
192- .putExtra (BasePlayer .START_PAUSED , !this .player .isPlaying ()));
187+ NavigationHelper .playOnMainPlayer (this , player .getPlayQueue (), true );
188+ return true ;
189+ case R .id .action_switch_popup :
190+ if (PermissionHelper .isPopupEnabled (this )) {
191+ this .player .setRecovery ();
192+ NavigationHelper .playOnPopupPlayer (this , player .playQueue , true );
193+ } else {
194+ PermissionHelper .showPopupEnablementToast (this );
195+ }
196+ return true ;
197+ case R .id .action_switch_background :
198+ this .player .setRecovery ();
199+ NavigationHelper .playOnBackgroundPlayer (this , player .playQueue , true );
193200 return true ;
194201 }
195- return onPlayerOptionSelected ( item ) || super .onOptionsItemSelected (item );
202+ return super .onOptionsItemSelected (item );
196203 }
197204
198205 @ Override
@@ -201,24 +208,6 @@ protected void onDestroy() {
201208 unbind ();
202209 }
203210
204- protected Intent getSwitchIntent (final Class clazz , final MainPlayer .PlayerType playerType ) {
205- return NavigationHelper .getPlayerIntent (getApplicationContext (), clazz ,
206- this .player .getPlayQueue (), this .player .getRepeatMode (),
207- this .player .getPlaybackSpeed (), this .player .getPlaybackPitch (),
208- this .player .getPlaybackSkipSilence (),
209- null ,
210- true ,
211- !this .player .isPlaying (),
212- this .player .isMuted ())
213- .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK )
214- .putExtra (Constants .KEY_LINK_TYPE , StreamingService .LinkType .STREAM )
215- .putExtra (Constants .KEY_URL , this .player .getVideoUrl ())
216- .putExtra (Constants .KEY_TITLE , this .player .getVideoTitle ())
217- .putExtra (Constants .KEY_SERVICE_ID ,
218- this .player .getCurrentMetadata ().getMetadata ().getServiceId ())
219- .putExtra (VideoPlayer .PLAYER_TYPE , playerType );
220- }
221-
222211 ////////////////////////////////////////////////////////////////////////////
223212 // Service Connection
224213 ////////////////////////////////////////////////////////////////////////////
@@ -368,8 +357,8 @@ private void buildItemPopupMenu(final PlayQueueItem item, final View view) {
368357 Menu .NONE , R .string .play_queue_stream_detail );
369358 detail .setOnMenuItemClickListener (menuItem -> {
370359 // playQueue is null since we don't want any queue change
371- NavigationHelper .openVideoDetail (
372- this , item .getServiceId (), item . getUrl (), item . getTitle (), null );
360+ NavigationHelper .openVideoDetail (this , item . getServiceId (), item . getUrl (),
361+ item .getTitle (), null , false );
373362 return true ;
374363 });
375364
0 commit comments