ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Exo-player notification resets to default UI state

Open sunnyadityaa opened this issue 8 years ago • 5 comments

Issue description

Exo-player notification resets to default sometimes while changing audioTracks. While changing audioTracks we are re-setting the player instance and removing the notification manager as well. Expected behavior Exo player notification should retain the state set.

Reproduction steps

  1. Remove navigation and stop action from notification
playerNotificationManager.setUseNavigationActions(false);
playerNotificationManager.setStopAction(null);
  1. Play audio
  2. Switch audio files
  3. Itermittently default player notification is seen

screenshot_20181017-164421-01 screenshot_20181017-164330-01

Link to test content

Not public yet

Version of ExoPlayer being used

2.9.0

Device(s) and version(s) of Android being used

Seen on multiple devices including pixel 2 running Android 28, Motorola G5sPLus on oreo and more

A full bug report captured from the device

N/A

sunnyadityaa avatar Oct 21 '18 17:10 sunnyadityaa

Is there a workaround for this issue?

nyjalusc avatar Oct 25 '18 21:10 nyjalusc

We tried sending the large icon update to notification manager with a delay. Reduced the frequency with which we were getting this.

Another thing this is reproduced even with a simple play/pause toggle from notification. What we are doing in pause/ play: we stop the foreground service and setOngoing() to false. To enable notification to be removed.

if (!playWhenReady) {
                    stopForeground(false);
                    playerNotificationManager.setOngoing(false);
                } else {
                    startForeground(notificationIdGlobal, notificationGlobal);
                    playerNotificationManager.setOngoing(true);
                }

SetOngoing internally calls to invalidate() that might be the issue that sometimes we end up with a default UI state.

sunnyadityaa avatar Oct 26 '18 06:10 sunnyadityaa

While changing audioTracks we are re-setting the player instance and removing the notification manager as well.

Is there a reason why you are resetting the player and remove the NotificationManager?

The state is kept in the NotificationManager. So when you do something like

playerNotificationManager.setUseNavigationActions(false);
playerNotificationManager.setStopAction(null);

the state is stored in the NotifcationManager. As long as you keep that instance the stop and navigation buttons are not shown anymore.

When you then create a new NotificationManager, like your comment suggests, you need to resume this state by calling these methods again. If you do this before you set the player again, this should actually work because the notification is only shown after the player is set again.

marcbaechinger avatar Nov 06 '18 19:11 marcbaechinger

Is there a reason why you are resetting the player and remove the NotificationManager?

We want the notification to be removable when paused so we stop and start the foreground service accordingly. The player and NotificationManager is reset only if a new song is played. Not in the case of toggling the play pause button.

I will try and update with the suggested actions.

sunnyadityaa avatar Nov 11 '18 16:11 sunnyadityaa

Issue was at our end in two places

  1. Loading image to display, there was a lag
  2. As @marcbaechinger suggested we needed to keep the same instance

sunnyadityaa avatar Dec 11 '18 08:12 sunnyadityaa