区分Android下RepeatMode和ShuffleMode的值

赵越
2023-12-01
  • RepeatMode
/**
     * @hide
     */
    @RestrictTo(LIBRARY_GROUP_PREFIX)
    @IntDef({REPEAT_MODE_INVALID, REPEAT_MODE_NONE, REPEAT_MODE_ONE, REPEAT_MODE_ALL,
            REPEAT_MODE_GROUP})
    @Retention(RetentionPolicy.SOURCE)
    public @interface RepeatMode {}

    /**
     * {@link MediaControllerCompat.TransportControls#getRepeatMode} returns this value
     * when the session is not ready for providing its repeat mode.
     */
    public static final int REPEAT_MODE_INVALID = -1;未指定重复播放模式

    /**
     * Use this value with {@link MediaControllerCompat.TransportControls#setRepeatMode}
     * to indicate that the playback will be stopped at the end of the playing media list.
     */
    public static final int REPEAT_MODE_NONE = 0; 播放媒体列表的末尾时 将停止播放

    /**
     * Use this value with {@link MediaControllerCompat.TransportControls#setRepeatMode}
     * to indicate that the playback of the current playing media item will be repeated.
     */
    public static final int REPEAT_MODE_ONE = 1; 单曲循环

    /**
     * Use this value with {@link MediaControllerCompat.TransportControls#setRepeatMode}
     * to indicate that the playback of the playing media list will be repeated.
     */
    public static final int REPEAT_MODE_ALL = 2; 列表循环

    /**
     * Use this value with {@link MediaControllerCompat.TransportControls#setRepeatMode}
     * to indicate that the playback of the playing media group will be repeated.
     * A group is a logical block of media items which is specified in the section 5.7 of the
     * Bluetooth AVRCP 1.6.
     */
    public static final int REPEAT_MODE_GROUP = 3; 列表循环,适用于蓝牙avrcp1.6协议,

REPEAT_MODE_GROUP猜测场景:
当使用蓝牙发生该命令时,控制播放端到下一个或者上一个组,而控制端不知道目标端的媒体存储机制。
蓝牙avrcp1.6中5.7部分的描述有以下介绍:

By doing this CT shall be able to move to next and previous groups
on TG(TG是目标端target) without any knowledge on the media storage
mechanism of TG.

例如:
假设一个U 盘中有多个目录a,b,c,每个目录下都有多个mp3文件,当前播放的为a目录下的列表,当播放的当前列表为最后一个时,如果此时的repeat模式为:REPEAT_MODE_GROUP,则切换当前的播放目录到下一个分组目录中,执行下一个目录的播放列表;如果此时的repeat模式为:REPEAT_MODE_ALL,则从当前播放列表的第一个继续播放。

  • ShuffleMode
  /**
     * @hide
     */
    @RestrictTo(LIBRARY_GROUP_PREFIX)
    @IntDef({SHUFFLE_MODE_INVALID, SHUFFLE_MODE_NONE, SHUFFLE_MODE_ALL, SHUFFLE_MODE_GROUP})
    @Retention(RetentionPolicy.SOURCE)
    public @interface ShuffleMode {}

    /**
     * {@link MediaControllerCompat.TransportControls#getShuffleMode} returns this value
     * when the session is not ready for providing its shuffle mode.
     */
    public static final int SHUFFLE_MODE_INVALID = -1; 未指定随机播放模式

    /**
     * Use this value with {@link MediaControllerCompat.TransportControls#setShuffleMode}
     * to indicate that the media list will be played in order.
     */
    public static final int SHUFFLE_MODE_NONE = 0;  顺序播放

    /**
     * Use this value with {@link MediaControllerCompat.TransportControls#setShuffleMode}
     * to indicate that the media list will be played in shuffled order.
     */
    public static final int SHUFFLE_MODE_ALL = 1; 列表随机播放

    /**
     * Use this value with {@link MediaControllerCompat.TransportControls#setShuffleMode}
     * to indicate that the media group will be played in shuffled order.
     * A group is a logical block of media items which is specified in the section 5.7 of the
     * Bluetooth AVRCP 1.6.
     */
         public static final int SHUFFLE_MODE_GROUP = 2;  列表随机播放  

SHUFFLE_MODE_GROUP猜测场景:
当使用蓝牙发生该命令时,控制播放端到下一个或者上一个组,而控制端不知道目标端的媒体存储机制。
协议中描述:

By doing this CT shall be able to move to next and previous groups on TG(TG是目标端target) without any knowledge on the media storage mechanism of TG.

例如:当播放的歌曲播放完成后,,如果此时的SHUFFLE模式为:SHUFFLE_MODE_GROUP,则在所有目录下进行随机播放;如果此时的SHUFFLE模式为:SHUFFLE_MODE_ALL,则从当前播放列表中进行随机播放。

 类似资料: