AVAudioSession BeginReceivingRemoteControlEvents never called

HAL9000HAL9000 FRMember
edited July 2014 in Xamarin.iOS


I try to use BeginReceivingRemoteControlEvents for my AVAudioSession player but my RemoteControlReceived method is never called.

In my ViewDidLoad :
UIApplication.SharedApplication.BeginReceivingRemoteControlEvents (); NSError error; AVAudioSession.SharedInstance ().WeakDelegate = this; AVAudioSession.SharedInstance ().SetCategory (AVAudioSessionCategory.Playback, AVAudioSessionCategoryOptions.DefaultToSpeaker); AVAudioSession.SharedInstance ().SetActive (true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation, out error);

And my method
public override void RemoteControlReceived (UIEvent theEvent) { base.RemoteControlReceived (theEvent); if (theEvent.Type == UIEventType.RemoteControl) { switch (theEvent.Subtype) { case UIEventSubtype.RemoteControlPause: _pl.Pause (); break; case UIEventSubtype.RemoteControlPlay: _pl.Play (); break; } } }

Thanks for your help


  • DannyCDannyC US ✭✭✭✭
    edited July 2014

    @MikalAMOUYAL , make sure you tell the app to start receiving them. For example add this to the ViewDidAppear:


    Update: sorry about that, noticed it was at the top of your code. The other thing I had to add was to make sure my ViewController was the firstResponder. I added this on my constructor:

    if (this.CanBecomeFirstResponder)
  • HAL9000HAL9000 FRMember

    Thanks a lot @DannyC‌ I forgot to put if (this.CanBecomeFirstResponder) this.BecomeFirstResponder(); to make sure my Controller was the firstResponder.


Sign In or Register to comment.