11

正如Apple文档中所述:

enum {
   MPMusicRepeatModeDefault,
   MPMusicRepeatModeNone,
   MPMusicRepeatModeOne,
   MPMusicRepeatModeAll
};
typedef NSInteger MPMusicRepeatMode;

然而,MPMusicRepeatModeDefault被描述为用户的首选重复模式。由于我正在编写音乐播放器,因此我每次都需要知道当前的重复模式是什么,以及当返回时,“实际”模式是什么:

  • MPMusicRepeatModeNone
  • MPMusicRepeatModeOne
  • MPMusicRepeatModeAll

应该被选中?还是没有办法得到这样的信息?

4

1 回答 1

4

我的理解是MPMusicRepeatModeDefault仅用于实例化您自己的播放器,如此所述。

MPMusicPlayerController* appMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];

// Use whatever the user has set in their iPod settings
// Omitting this line has no real effect because deferring to the
// user mode is the default setting for new players
[appMusicPlayer setRepeatMode: MPMusicRepeatModeDefault];

如果您想知道该默认设置实际上是什么,您应该能够从iPodMusicPlayer 实例中获取它:

MPMusicPlayerController* iPodMusicPlayer =
    [MPMusicPlayerController iPodMusicPlayer];

MPMusicRepeatMode theDefaultMode = [iPodMusicPlayer repeatMode];
于 2012-12-17T11:38:03.480 回答