@@ -199,8 +199,8 @@ default void onForegroundServiceStartNotAllowedException() {}
199199 public @interface ShowNotificationForIdlePlayerMode {}
200200
201201 /**
202- * Always show a notification when the {@link Player} is in {@link Player#STATE_IDLE}, has media,
203- * and the notification wasn't explicitly dismissed.
202+ * Always show a notification when the {@link Player} is in {@link Player#STATE_IDLE} and the
203+ * notification wasn't explicitly dismissed.
204204 */
205205 @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_IDLE_PLAYER_ALWAYS = 1 ;
206206
@@ -209,10 +209,45 @@ default void onForegroundServiceStartNotAllowedException() {}
209209
210210 /**
211211 * Shows a notification when the {@link Player} is in {@link Player#STATE_IDLE} due to {@link
212- * Player#stop} or an error, has media, and the notification wasn't explicitly dismissed.
212+ * Player#stop} or an error, and the notification wasn't explicitly dismissed.
213213 */
214214 @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_IDLE_PLAYER_AFTER_STOP_OR_ERROR = 3 ;
215215
216+ /**
217+ * The behavior for showing notifications when the {@link Player} has no media.
218+ *
219+ * <p>One of {@link #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_ALWAYS}, {@link
220+ * #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER}, {@link
221+ * #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_AFTER_STOP_OR_ERROR}.
222+ *
223+ * <p>The default value is {@link #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER}.
224+ */
225+ @ UnstableApi
226+ @ Documented
227+ @ Retention (RetentionPolicy .SOURCE )
228+ @ Target (TYPE_USE )
229+ @ IntDef ({
230+ SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_ALWAYS ,
231+ SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER ,
232+ SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_AFTER_STOP_OR_ERROR
233+ })
234+ public @interface ShowNotificationForEmptyPlayerMode {}
235+
236+ /**
237+ * Always show a notification when the {@link Player} is empty and the notification wasn't
238+ * explicitly dismissed.
239+ */
240+ @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_ALWAYS = 1 ;
241+
242+ /** Never show a notification when the {@link Player} is empty. */
243+ @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER = 2 ;
244+
245+ /**
246+ * Shows a notification when the {@link Player} is empty, in {@link Player#STATE_IDLE} due to
247+ * {@link Player#stop} or an error, and the notification wasn't explicitly dismissed.
248+ */
249+ @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_AFTER_STOP_OR_ERROR = 3 ;
250+
216251 private static final String TAG = "MSessionService" ;
217252
218253 private final Object lock ;
@@ -595,6 +630,18 @@ public final void setShowNotificationForIdlePlayer(
595630 .setShowNotificationForIdlePlayer (showNotificationForIdlePlayerMode );
596631 }
597632
633+ /**
634+ * Sets whether and when a notification for a {@link Player} that has no media should be shown.
635+ *
636+ * @param showNotificationForEmptyPlayerMode The {@link ShowNotificationForEmptyPlayerMode}.
637+ */
638+ @ UnstableApi
639+ public final void setShowNotificationForEmptyPlayer (
640+ @ ShowNotificationForEmptyPlayerMode int showNotificationForEmptyPlayerMode ) {
641+ getMediaNotificationManager ()
642+ .setShowNotificationForEmptyPlayer (showNotificationForEmptyPlayerMode );
643+ }
644+
598645 /**
599646 * Returns whether there is a session with ongoing user-engaged playback that is run in a
600647 * foreground service.
0 commit comments