如何使用earPods遥控器控制AVAudioPlayer?

时间:2015-11-05 14:34:36

标签: swift avaudioplayer remote-control headphones

我使用AVAudioPlayer播放音乐

我想通过使用耳机的遥控器来控制播放。

我已经这样了:

override func remoteControlReceivedWithEvent(event: UIEvent?) {
        let rc = event!.subtype
        print(rc.rawValue)
        //rc.rawValue: 101 = pause, 100 = play
        switch rc {
        case .RemoteControlPlay:

            playButtonClicked("")

        case .RemoteControlPause:

            pauseButtonClicked("")

        default:break
        }

    }

从这个菜单中工作得很好

但忽略了对耳机的点击。我该如何解决?

1 个答案:

答案 0 :(得分:0)

我相信耳机会发送<?php foreach ($id as $row) { echo "<option value='" . $row->groupID . " ' >" . $row->groupID . " </option>"; } ?> 事件:

https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPRemoteCommandCenter_Ref/index.html#//apple_ref/occ/instp/MPRemoteCommandCenter/togglePlayPauseCommand

因为我看到您正在使用Xamarin,所以TogglePlayPauseCommand会感兴趣

https://developer.xamarin.com/api/type/MonoTouch.UIKit.UIEventSubtype/