PlayerNotificationManager

PlayerNotificationManager

我使用的是Exoplayer 2.11.0版,我想知道当用户向右滑动(类似于Spotify)时是否有可能停止PlayerNotificationManager。默认情况下,我只能调用useStopAction(true)https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/ui/PlayerNotificationManager.html
这让我不满意。

java - Exoplayer PlayerNotificationManager onSwipe-LMLPHP

最佳答案

   @Override
                public void onNotificationPosted(int notificationId, Notification notification, boolean ongoing) {
                    if (ongoing) {
                        // Make sure the service will not get destroyed while playing media.
                        startForeground(notificationId, notification);
                    } else {
                        // Make notification cancellable.
                        stopForeground(false);
                    }
                }

10-08 00:36