@@ -194,8 +194,8 @@ default void onForegroundServiceStartNotAllowedException() {}
194194 public @interface ShowNotificationForIdlePlayerMode {}
195195
196196 /**
197- * Always show a notification when the {@link Player} is in {@link Player#STATE_IDLE}, has media,
198- * and the notification wasn't explicitly dismissed.
197+ * Always show a notification when the {@link Player} is in {@link Player#STATE_IDLE} and the
198+ * notification wasn't explicitly dismissed.
199199 */
200200 @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_IDLE_PLAYER_ALWAYS = 1 ;
201201
@@ -204,10 +204,46 @@ default void onForegroundServiceStartNotAllowedException() {}
204204
205205 /**
206206 * Shows a notification when the {@link Player} is in {@link Player#STATE_IDLE} due to {@link
207- * Player#stop} or an error, has media, and the notification wasn't explicitly dismissed.
207+ * Player#stop} or an error, and the notification wasn't explicitly dismissed.
208208 */
209209 @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_IDLE_PLAYER_AFTER_STOP_OR_ERROR = 3 ;
210210
211+ /**
212+ * The behavior for showing notifications when the {@link Player} has no media.
213+ *
214+ * <p>One of {@link #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_ALWAYS}, {@link
215+ * #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER}, {@link
216+ * #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_AFTER_STOP_OR_ERROR}.
217+ *
218+ * <p>The default value is {@link #SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER}.
219+ */
220+ @ UnstableApi
221+ @ Documented
222+ @ Retention (RetentionPolicy .SOURCE )
223+ @ Target (TYPE_USE )
224+ @ IntDef ({
225+ SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_ALWAYS ,
226+ SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER ,
227+ SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_AFTER_STOP_OR_ERROR
228+ })
229+ public @interface ShowNotificationForEmptyPlayerMode {}
230+
231+ /**
232+ * Always show a notification when the {@link Player} is empty and the notification wasn't
233+ * explicitly dismissed.
234+ */
235+ @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_ALWAYS = 1 ;
236+
237+ /** Never show a notification when the {@link Player} is empty. */
238+ @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_NEVER = 2 ;
239+
240+ /**
241+ * Shows a notification when the {@link Player} is empty, in {@link Player#STATE_IDLE} due to {
242+ *
243+ * @link Player#stop} or an error, and the notification wasn't explicitly dismissed.
244+ */
245+ @ UnstableApi public static final int SHOW_NOTIFICATION_FOR_EMPTY_PLAYER_AFTER_STOP_OR_ERROR = 3 ;
246+
211247 private static final String TAG = "MSessionService" ;
212248
213249 private final Object lock ;
@@ -547,6 +583,18 @@ public final void setShowNotificationForIdlePlayer(
547583 .setShowNotificationForIdlePlayer (showNotificationForIdlePlayerMode );
548584 }
549585
586+ /**
587+ * Sets whether and when a notification for a {@link Player} that has no media should be shown.
588+ *
589+ * @param showNotificationForEmptyPlayerMode The {@link ShowNotificationForEmptyPlayerMode}.
590+ */
591+ @ UnstableApi
592+ public final void setShowNotificationForEmptyPlayer (
593+ @ ShowNotificationForEmptyPlayerMode int showNotificationForEmptyPlayerMode ) {
594+ getMediaNotificationManager ()
595+ .setShowNotificationForEmptyPlayer (showNotificationForEmptyPlayerMode );
596+ }
597+
550598 /**
551599 * Returns whether there is a session with ongoing user-engaged playback that is run in a
552600 * foreground service.
0 commit comments