How can we handle headphone play/pause button events in foreground in ios

后端 未结 3 650
南旧
南旧 2021-02-06 05:31

I have an requirement that to handle headphone play/pause button events in foreground. How ever I am able to handle the same scenario in background using the below code

3条回答
  •  礼貌的吻别
    2021-02-06 06:29

    There is another way to implement player control from headphones. use MPRemoteCommandCenter tooglePlayPauseCommand. Apple documentation

    [[MPRemoteCommandCenter sharedCommandCenter].togglePlayPauseCommand addTarget:self action:@selector(onTooglePlayPause)];
    

提交回复
热议问题