mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	-Added back button press check to destroy rather than minimize main video player.
This commit is contained in:
		| @@ -104,6 +104,7 @@ public final class MainVideoPlayer extends AppCompatActivity | ||||
|  | ||||
|     @Nullable private PlayerState playerState; | ||||
|     private boolean isInMultiWindow; | ||||
|     private boolean isBackPressed; | ||||
|  | ||||
|     /*////////////////////////////////////////////////////////////////////////// | ||||
|     // Activity LifeCycle | ||||
| @@ -191,6 +192,12 @@ public final class MainVideoPlayer extends AppCompatActivity | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onBackPressed() { | ||||
|         super.onBackPressed(); | ||||
|         isBackPressed = true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onSaveInstanceState(Bundle outState) { | ||||
|         if (DEBUG) Log.d(TAG, "onSaveInstanceState() called"); | ||||
| @@ -211,9 +218,15 @@ public final class MainVideoPlayer extends AppCompatActivity | ||||
|         PlayerHelper.setScreenBrightness(getApplicationContext(), | ||||
|                 getWindow().getAttributes().screenBrightness); | ||||
|  | ||||
|         isInMultiWindow = false; | ||||
|         if (playerImpl == null) return; | ||||
|         if (isBackPressed) { | ||||
|             playerImpl.destroy(); | ||||
|         } else { | ||||
|             playerImpl.minimize(); | ||||
|         } | ||||
|  | ||||
|         if (playerImpl != null) playerImpl.terminate(); | ||||
|         isInMultiWindow = false; | ||||
|         isBackPressed = false; | ||||
|     } | ||||
|  | ||||
|     /*////////////////////////////////////////////////////////////////////////// | ||||
| @@ -443,7 +456,7 @@ public final class MainVideoPlayer extends AppCompatActivity | ||||
|             switchPopupButton.setOnClickListener(this); | ||||
|         } | ||||
|  | ||||
|         public void terminate() { | ||||
|         public void minimize() { | ||||
|             switch (PlayerHelper.getMinimizeOnExitAction(context)) { | ||||
|                 case PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_BACKGROUND: | ||||
|                     onPlayBackgroundButtonClicked(); | ||||
|   | ||||
| @@ -505,8 +505,8 @@ | ||||
|     </string-array> | ||||
|  | ||||
|     <!-- Minimize to exit action --> | ||||
|     <string name="minimize_on_exit_title">Minimize on exit</string> | ||||
|     <string name="minimize_on_exit_summary">Action when exiting main video player — %s</string> | ||||
|     <string name="minimize_on_exit_title">Minimize on application switch</string> | ||||
|     <string name="minimize_on_exit_summary">Action when switching to other application from main video player — %s</string> | ||||
|     <string name="minimize_on_exit_none_description">None</string> | ||||
|     <string name="minimize_on_exit_background_description">Minimize to background player</string> | ||||
|     <string name="minimize_on_exit_popup_description">Minimize to popup player</string> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 John Zhen Mo
					John Zhen Mo