@@ -98,7 +98,6 @@ public class MainVideoPlayer extends Service {
98
98
99
99
private VideoPlayerImpl playerImpl ;
100
100
public boolean isFullscreen = false ;
101
- private ImageButton screenRotationButton ;
102
101
103
102
private PlayerEventListener fragmentListener ;
104
103
private final IBinder mBinder = new MainVideoPlayer .LocalBinder ();
@@ -165,9 +164,6 @@ private void createView() {
165
164
playerImpl = new VideoPlayerImpl (this );
166
165
playerImpl .setStartedFromNewPipe (true );
167
166
playerImpl .setup (layout );
168
-
169
- screenRotationButton = layout .findViewById (R .id .screenRotationButton );
170
- checkAutorotation ();
171
167
}
172
168
173
169
public void stop () {
@@ -229,11 +225,6 @@ public void loadVideo(StreamInfo info, PlayQueue queue, String videoResolution,
229
225
getView ().findViewById (R .id .surfaceView ).setVisibility (View .GONE );
230
226
}
231
227
232
- public void checkAutorotation () {
233
- boolean autorotationEnabled = PreferenceManager .getDefaultSharedPreferences (this ).getBoolean (this .getString (R .string .use_video_autorotation_key ), false );
234
- screenRotationButton .setVisibility (autorotationEnabled ? View .GONE : View .VISIBLE );
235
- }
236
-
237
228
private void toggleOrientation () {
238
229
Activity parent = playerImpl .getParentActivity ();
239
230
if (parent == null ) return ;
@@ -354,6 +345,7 @@ public class VideoPlayerImpl extends VideoPlayer {
354
345
private ImageButton queueButton ;
355
346
private ImageButton repeatButton ;
356
347
private ImageButton shuffleButton ;
348
+ private ImageButton screenRotationButton ;
357
349
358
350
private ImageButton playPauseButton ;
359
351
private ImageButton playPreviousButton ;
@@ -393,7 +385,7 @@ public void initViews(View rootView) {
393
385
this .queueButton = rootView .findViewById (R .id .queueButton );
394
386
this .repeatButton = rootView .findViewById (R .id .repeatButton );
395
387
this .shuffleButton = rootView .findViewById (R .id .shuffleButton );
396
-
388
+ this . screenRotationButton = rootView . findViewById ( R . id . screenRotationButton );
397
389
this .playPauseButton = rootView .findViewById (R .id .playPauseButton );
398
390
this .playPreviousButton = rootView .findViewById (R .id .playPreviousButton );
399
391
this .playNextButton = rootView .findViewById (R .id .playNextButton );
@@ -403,6 +395,7 @@ public void initViews(View rootView) {
403
395
404
396
titleTextView .setSelected (true );
405
397
channelTextView .setSelected (true );
398
+ checkAutorotation ();
406
399
407
400
getRootView ().setKeepScreenOn (true );
408
401
}
@@ -423,6 +416,7 @@ public void initListeners() {
423
416
playPauseButton .setOnClickListener (this );
424
417
playPreviousButton .setOnClickListener (this );
425
418
playNextButton .setOnClickListener (this );
419
+ screenRotationButton .setOnClickListener (this );
426
420
moreOptionsButton .setOnClickListener (this );
427
421
}
428
422
@@ -528,7 +522,6 @@ public void onPlayBackgroundButtonClicked() {
528
522
529
523
((View ) getControlAnimationView ().getParent ()).setVisibility (View .GONE );
530
524
destroy ();
531
- finish ();
532
525
}
533
526
534
527
@@ -544,6 +537,9 @@ public void onClick(View v) {
544
537
} else if (v .getId () == playNextButton .getId ()) {
545
538
onPlayNext ();
546
539
540
+ } else if (v .getId () == screenRotationButton .getId ()) {
541
+ onScreenRotationClicked ();
542
+
547
543
} else if (v .getId () == queueButton .getId ()) {
548
544
onQueueClicked ();
549
545
return ;
@@ -800,6 +796,16 @@ public void onBroadcastReceived(Intent intent) {
800
796
}
801
797
resetNotification ();
802
798
}
799
+ /*@Override
800
+ public void onConfigurationChanged(Configuration newConfig) {
801
+ super.onConfigurationChanged(newConfig);
802
+
803
+ if (playerImpl.isSomePopupMenuVisible()) {
804
+ playerImpl.moreOptionsPopupMenu.dismiss();
805
+ playerImpl.getQualityPopupMenu().dismiss();
806
+ playerImpl.getPlaybackSpeedPopupMenu().dismiss();
807
+ }
808
+ }*/
803
809
804
810
/*//////////////////////////////////////////////////////////////////////////
805
811
// Utils
@@ -894,6 +900,11 @@ private void updatePlaybackButtons() {
894
900
setShuffleButton (shuffleButton , playQueue .isShuffled ());
895
901
}
896
902
903
+ public void checkAutorotation () {
904
+ boolean autorotationEnabled = PreferenceManager .getDefaultSharedPreferences (getApplicationContext ()).getBoolean (getApplication ().getString (R .string .use_video_autorotation_key ), false );
905
+ screenRotationButton .setVisibility (autorotationEnabled ? View .GONE : View .VISIBLE );
906
+ }
907
+
897
908
private void buildMoreOptionsMenu () {
898
909
if (moreOptionsPopupMenu == null ) return ;
899
910
moreOptionsPopupMenu .setOnMenuItemClickListener (new PopupMenu .OnMenuItemClickListener () {
0 commit comments