@@ -236,11 +236,14 @@ public final class VideoDetailFragment
236236 // Service management
237237 //////////////////////////////////////////////////////////////////////////*/
238238 @ Override
239- public void onServiceConnected (final Player connectedPlayer ,
240- final PlayerService connectedPlayerService ,
241- final boolean playAfterConnect ) {
242- player = connectedPlayer ;
239+ public void onServiceConnected (@ NonNull final PlayerService connectedPlayerService ) {
243240 playerService = connectedPlayerService ;
241+ }
242+
243+ @ Override
244+ public void onPlayerConnected (@ NonNull final Player connectedPlayer ,
245+ final boolean playAfterConnect ) {
246+ player = connectedPlayer ;
244247
245248 // It will do nothing if the player is not in fullscreen mode
246249 hideSystemUiIfNeeded ();
@@ -272,11 +275,18 @@ && isAutoplayEnabled()
272275 updateOverlayPlayQueueButtonVisibility ();
273276 }
274277
278+ @ Override
279+ public void onPlayerDisconnected () {
280+ player = null ;
281+ // the binding could be null at this point, if the app is finishing
282+ if (binding != null ) {
283+ restoreDefaultBrightness ();
284+ }
285+ }
286+
275287 @ Override
276288 public void onServiceDisconnected () {
277289 playerService = null ;
278- player = null ;
279- restoreDefaultBrightness ();
280290 }
281291
282292
@@ -1848,13 +1858,16 @@ public void onPlayerError(final PlaybackException error, final boolean isCatchab
18481858
18491859 @ Override
18501860 public void onServiceStopped () {
1851- setOverlayPlayPauseImage (false );
1852- if (currentInfo != null ) {
1853- updateOverlayData (currentInfo .getName (),
1854- currentInfo .getUploaderName (),
1855- currentInfo .getThumbnails ());
1861+ // the binding could be null at this point, if the app is finishing
1862+ if (binding != null ) {
1863+ setOverlayPlayPauseImage (false );
1864+ if (currentInfo != null ) {
1865+ updateOverlayData (currentInfo .getName (),
1866+ currentInfo .getUploaderName (),
1867+ currentInfo .getThumbnails ());
1868+ }
1869+ updateOverlayPlayQueueButtonVisibility ();
18561870 }
1857- updateOverlayPlayQueueButtonVisibility ();
18581871 }
18591872
18601873 @ Override
0 commit comments