private void AudioInterruption(object sender, AVAudioSessionInterruptionEventArgs e) { if (e.InterruptionType == AVAudioSessionInterruptionType.Ended && audioPlayer.LastAudioAction == AudioAction.Play) { audioPlayer.Play(); } }
void InterruptAudio(object sender, AVAudioSessionInterruptionEventArgs e) { if (e.InterruptionType == AVAudioSessionInterruptionType.Began) { AVAudioSession.SharedInstance().SetActive(false, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation); } else { AVAudioSession.SharedInstance().SetActive(true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation); } }
private void OnAnotherSessionStarts(object sender, AVAudioSessionInterruptionEventArgs args) { if (soundRecorder != null && soundRecorder.Active) { if (args.InterruptionType == AVAudioSessionInterruptionType.Began) { // Cancel process, and do not start it again because of it means user start do something another // and will restart process if necessary Cancel(); } } }
// [Export("beginInterruption")] void Interruption(object sender, AVAudioSessionInterruptionEventArgs e) { if (e.InterruptionType == AVAudioSessionInterruptionType.Began) { stopAudioProcessingGraph(); } else if (e.InterruptionType == AVAudioSessionInterruptionType.Ended) { NSError error = null; AVAudioSession.SharedInstance().SetActive(true, out error); if (error != null) { Console.WriteLine("Unable to reactivate the audio session"); return; } if (e.Option == AVAudioSessionInterruptionOptions.ShouldResume) { restartAudioProcessingGraph(); } } }
// [Export("beginInterruption")] void Interruption (object sender, AVAudioSessionInterruptionEventArgs e) { if (e.InterruptionType == AVAudioSessionInterruptionType.Began) stopAudioProcessingGraph (); else if (e.InterruptionType == AVAudioSessionInterruptionType.Ended) { NSError error = null; AVAudioSession.SharedInstance ().SetActive (true, out error); if (error != null) { Console.WriteLine ("Unable to reactivate the audio session"); return; } if (e.Option == AVAudioSessionInterruptionOptions.ShouldResume) restartAudioProcessingGraph (); } }