@@ -262,6 +262,7 @@ && isAutoplayEnabled()
262262 autoPlayEnabled = true ; // forcefully start playing
263263 openVideoPlayerAutoFullscreen ();
264264 }
265+ updateOverlayPlayQueueButtonVisibility ();
265266 }
266267
267268 @ Override
@@ -351,6 +352,8 @@ public void onResume() {
351352
352353 activity .sendBroadcast (new Intent (ACTION_VIDEO_FRAGMENT_RESUMED ));
353354
355+ updateOverlayPlayQueueButtonVisibility ();
356+
354357 setupBrightness ();
355358
356359 if (tabSettingsChanged ) {
@@ -610,19 +613,7 @@ protected void initViews(final View rootView, final Bundle savedInstanceState) {
610613 ? View .VISIBLE
611614 : View .GONE
612615 );
613-
614- if (DeviceUtils .isTv (getContext ())) {
615- // remove ripple effects from detail controls
616- final int transparent = ContextCompat .getColor (requireContext (),
617- R .color .transparent_background_color );
618- binding .detailControlsPlaylistAppend .setBackgroundColor (transparent );
619- binding .detailControlsBackground .setBackgroundColor (transparent );
620- binding .detailControlsPopup .setBackgroundColor (transparent );
621- binding .detailControlsDownload .setBackgroundColor (transparent );
622- binding .detailControlsShare .setBackgroundColor (transparent );
623- binding .detailControlsOpenInBrowser .setBackgroundColor (transparent );
624- binding .detailControlsPlayWithKodi .setBackgroundColor (transparent );
625- }
616+ accommodateForTvAndDesktopMode ();
626617 }
627618
628619 @ Override
@@ -1758,6 +1749,14 @@ public void onQueueUpdate(final PlayQueue queue) {
17581749 + title + "], playQueue = [" + playQueue + "]" );
17591750 }
17601751
1752+ // Register broadcast receiver to listen to playQueue changes
1753+ // and hide the overlayPlayQueueButton when the playQueue is empty / destroyed.
1754+ if (playQueue != null && playQueue .getBroadcastReceiver () != null ) {
1755+ playQueue .getBroadcastReceiver ().subscribe (
1756+ event -> updateOverlayPlayQueueButtonVisibility ()
1757+ );
1758+ }
1759+
17611760 // This should be the only place where we push data to stack.
17621761 // It will allow to have live instance of PlayQueue with actual information about
17631762 // deleted/added items inside Channel/Playlist queue and makes possible to have
@@ -1864,6 +1863,7 @@ public void onServiceStopped() {
18641863 currentInfo .getUploaderName (),
18651864 currentInfo .getThumbnailUrl ());
18661865 }
1866+ updateOverlayPlayQueueButtonVisibility ();
18671867 }
18681868
18691869 @ Override
@@ -2044,6 +2044,30 @@ private void setupBrightness() {
20442044 }
20452045 }
20462046
2047+ /**
2048+ * Make changes to the UI to accommodate for better usability on bigger screens such as TVs
2049+ * or in Android's desktop mode (DeX etc).
2050+ */
2051+ private void accommodateForTvAndDesktopMode () {
2052+ if (DeviceUtils .isTv (getContext ())) {
2053+ // remove ripple effects from detail controls
2054+ final int transparent = ContextCompat .getColor (requireContext (),
2055+ R .color .transparent_background_color );
2056+ binding .detailControlsPlaylistAppend .setBackgroundColor (transparent );
2057+ binding .detailControlsBackground .setBackgroundColor (transparent );
2058+ binding .detailControlsPopup .setBackgroundColor (transparent );
2059+ binding .detailControlsDownload .setBackgroundColor (transparent );
2060+ binding .detailControlsShare .setBackgroundColor (transparent );
2061+ binding .detailControlsOpenInBrowser .setBackgroundColor (transparent );
2062+ binding .detailControlsPlayWithKodi .setBackgroundColor (transparent );
2063+ }
2064+ if (DeviceUtils .isDesktopMode (getContext ())) {
2065+ // Remove the "hover" overlay (since it is visible on all mouse events and interferes
2066+ // with the video content being played)
2067+ binding .detailThumbnailRootLayout .setForeground (null );
2068+ }
2069+ }
2070+
20472071 private void checkLandscape () {
20482072 if ((!player .isPlaying () && player .getPlayQueue () != playQueue )
20492073 || player .getPlayQueue () == null ) {
@@ -2330,6 +2354,18 @@ public void onSlide(@NonNull final View bottomSheet, final float slideOffset) {
23302354 });
23312355 }
23322356
2357+ private void updateOverlayPlayQueueButtonVisibility () {
2358+ final boolean isPlayQueueEmpty =
2359+ player == null // no player => no play queue :)
2360+ || player .getPlayQueue () == null
2361+ || player .getPlayQueue ().isEmpty ();
2362+ if (binding != null ) {
2363+ // binding is null when rotating the device...
2364+ binding .overlayPlayQueueButton .setVisibility (
2365+ isPlayQueueEmpty ? View .GONE : View .VISIBLE );
2366+ }
2367+ }
2368+
23332369 private void updateOverlayData (@ Nullable final String overlayTitle ,
23342370 @ Nullable final String uploader ,
23352371 @ Nullable final String thumbnailUrl ) {
0 commit comments