@@ -248,6 +248,7 @@ && isAutoplayEnabled()
248248 autoPlayEnabled = true ; // forcefully start playing
249249 openVideoPlayerAutoFullscreen ();
250250 }
251+ updateOverlayPlayQueueButtonVisibility ();
251252 }
252253
253254 @ Override
@@ -337,6 +338,8 @@ public void onResume() {
337338
338339 activity .sendBroadcast (new Intent (ACTION_VIDEO_FRAGMENT_RESUMED ));
339340
341+ updateOverlayPlayQueueButtonVisibility ();
342+
340343 setupBrightness ();
341344
342345 if (tabSettingsChanged ) {
@@ -1820,6 +1823,14 @@ public void onQueueUpdate(final PlayQueue queue) {
18201823 + title + "], playQueue = [" + playQueue + "]" );
18211824 }
18221825
1826+ // Register broadcast receiver to listen to playQueue changes
1827+ // and hide the overlayPlayQueueButton when the playQueue is empty / destroyed.
1828+ if (playQueue != null && playQueue .getBroadcastReceiver () != null ) {
1829+ playQueue .getBroadcastReceiver ().subscribe (
1830+ event -> updateOverlayPlayQueueButtonVisibility ()
1831+ );
1832+ }
1833+
18231834 // This should be the only place where we push data to stack.
18241835 // It will allow to have live instance of PlayQueue with actual information about
18251836 // deleted/added items inside Channel/Playlist queue and makes possible to have
@@ -1926,6 +1937,7 @@ public void onServiceStopped() {
19261937 currentInfo .getUploaderName (),
19271938 currentInfo .getThumbnailUrl ());
19281939 }
1940+ updateOverlayPlayQueueButtonVisibility ();
19291941 }
19301942
19311943 @ Override
@@ -2392,6 +2404,18 @@ public void onSlide(@NonNull final View bottomSheet, final float slideOffset) {
23922404 });
23932405 }
23942406
2407+ private void updateOverlayPlayQueueButtonVisibility () {
2408+ final boolean isPlayQueueEmpty =
2409+ player == null // no player => no play queue :)
2410+ || player .getPlayQueue () == null
2411+ || player .getPlayQueue ().isEmpty ();
2412+ if (binding != null ) {
2413+ // binding is null when rotating the device...
2414+ binding .overlayPlayQueueButton .setVisibility (
2415+ isPlayQueueEmpty ? View .GONE : View .VISIBLE );
2416+ }
2417+ }
2418+
23952419 private void updateOverlayData (@ Nullable final String overlayTitle ,
23962420 @ Nullable final String uploader ,
23972421 @ Nullable final String thumbnailUrl ) {
0 commit comments