如何检测耳机上的远程暂停与来电区分?

3
我希望我的应用程序能够在用户暂停耳机音乐时暂停。
[[NSNotificationCenter defaultCenter] addObserver:self 
  selector:@selector(playbackStateDidChange:) 
  name:MPMusicPlayerControllerPlaybackStateDidChangeNotification 
  object:[MPMusicPlayerController iPodMusicPlayer]];

功能非常好。然而,这也会在接收到电话时触发。

我添加了

[[NSNotificationCenter defaultCenter] addObserver:self 
  selector:@selector(appLostFocus:) 
  name:UIApplicationWillResignActiveNotification 
  object:[UIApplication sharedApplication]];

不幸的是,这是在检测到暂停后触发的。

有什么想法吗?

1个回答

0

目前没有记录的方法可以做到这一点。可能可以使用私有API实现,但你知道这首歌怎么唱。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接