-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audio for IOS is coming out of ear speaker and not main speakers. #52
Comments
did you find a solution for this. I am having the same exact problem. It changes all the audio output of my app to the ear speaker. I wonder if you found a work around to this issue. Thanks. |
Have not found a work around. I did notice that if you close the app and then reopen it then all speakers
work. However, when you record it switches it back. I got pulled in a different direction. Going to get back into
this later this week. Wondered if a way exists to reset speakers after recording finishes. Let me know if you have
any luck. Thanks.
From: fliot4u <[email protected]>
Sent: Tuesday, July 21, 2020 12:14 PM
To: NateRickard/Plugin.AudioRecorder <[email protected]>
Cc: JimAdamsdev <[email protected]>; Author <[email protected]>
Subject: Re: [NateRickard/Plugin.AudioRecorder] Audio for IOS is coming out of ear speaker and not main speakers. (#52)
did you find a solution for this. I am having the same exact problem. It changes all the audio output of my app to the ear speaker. I wonder if you found a work around to this issue. Thanks.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#52 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQE5BIZONNM3CSIBZNQGL2TR4W5FTANCNFSM4OPAXMNQ> .
|
I did found a solution or workaround. and create a class AudioService.cs that implements it just like this: namespace .iOS
} then in your event clicked do something like this: private void Recorder_AudioInputReceived(object sender, string audioFile)
basically we are changing from the main speakers to the ear speakers. but as I notice if we are going to record we need to set it as ear speakers for that but we can easily change it back when we are done recording. Hope it helps! Good Luck! |
Thanks! 😊 My android phone has only one speaker. Have you tested to see if its also occuring on Android?
From: fliot4u <[email protected]>
Sent: Tuesday, July 21, 2020 2:14 PM
To: NateRickard/Plugin.AudioRecorder <[email protected]>
Cc: JimAdamsdev <[email protected]>; Author <[email protected]>
Subject: Re: [NateRickard/Plugin.AudioRecorder] Audio for IOS is coming out of ear speaker and not main speakers. (#52)
I did found a solution or workaround.
Create an interface on your share project like this:
namespace .IOS
{
public interface IAudioService
{
}
}
and create a class AudioService.cs that implements it just like this:
using System;
using AVFoundation;
using Foundation;
namespace .iOS
{
public class AudioService : IAudioService
{
public AudioService()
{
}
public void PlaySoundThroughSpeaker()
{
var session = AVAudioSession.SharedInstance();
session.SetCategory(AVAudioSessionCategory.Playback);
session.SetActive(true);
}
public void PlaySoundThroughEarPiece()
{
var session = AVAudioSession.SharedInstance();
session.SetCategory(AVAudioSessionCategory.PlayAndRecord);
session.SetActive(true);
}
}
}
then in your event clicked do something like this:
void RecordClicked(System.Object sender, System.EventArgs e)
{
var audioService = new AudioService();
audioService.PlaySoundThroughEarPiece();
RecordAudio();
}
because before recording we have to allow the phone to use the microphone and ear speaker.
and then in wherever you handle the audio file created by the recorder add this code at the end:
private void Recorder_AudioInputReceived(object sender, string audioFile)
{
DisplayAlert("Notification", "Audio Message Sent Succesfully!", "Close");
var audioService = new AudioService();
audioService.PlaySoundThroughSpeaker();
}
basically we are changing from the main speakers to the ear speakers. but as I notice if we are going to record we need to set it as ear speakers for that but we can easily change it back when we are done recording. Hope it helps! Good Luck!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#52 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQE5BI5DCAIGPBVUHJ7GXZDR4XLHLANCNFSM4OPAXMNQ> .
|
At least for me the android side doesn't give any issues. |
#if IOS and implementing a AudioService in Xamarin iOS for a DependencyInjection with much the same code as above (fliot4u) worked for me. Android ok out of the box. |
When I play audio the sound just comes out of the ear speaker for IOS. Can I do something to change this to come out of all the speakers or switch to the main speaker? Thanks in advance for your help.
Jim
The text was updated successfully, but these errors were encountered: