【问题标题】:Get notification when iPod music is stopped当 iPod 音乐停止时获取通知
【发布时间】:2011-01-24 18:46:29
【问题描述】:

当没有其他 (iPod) 音乐正在播放时,我需要在我的应用中播放背景音乐。我可以在初始化我的音频会话时确定它:

AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying);

但我还想在用户停止 iPod 播放器时播放我的背景音乐(按两次主页按钮并暂停音乐)。我怎样才能捕捉到这个事件?

【问题讨论】:

    标签: iphone session audio ipod


    【解决方案1】:

    我找到了:

    [[NSNotificationCenter defaultCenter] addObserver: self 
        selector: @selector (onIPodPlayerPlaybackStateChanged:)
        name: MPMusicPlayerControllerPlaybackStateDidChangeNotification 
        object: [MPMusicPlayerController iPodMusicPlayer]];
    [[MPMusicPlayerController iPodMusicPlayer] beginGeneratingPlaybackNotifications];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-27
      • 1970-01-01
      • 2011-10-06
      • 1970-01-01
      相关资源
      最近更新 更多