Closed JijeshP closed 5 years ago
webrtc.speakerEnabled(true)
@triniwiz I tried using this.webrtc.speakerEnabled(true);
but it's not working in iOS.
https://github.com/triniwiz/nativescript-webrtc/blob/master/src/webrtc.ios.ts#L435 is the code used guessing some error could be throwing but i'm not logging it you can try throwing in a log there
Logging below error NSErrorWrapper: Must call lockForConfiguration before calling this method.
Thanks for the update will publish a new fix soon
This fix did not resolve the issue for me (on iPhone XS / iOS 12), so I wrote this piece of code that fixed it:
NSNotificationCenter.defaultCenter.addObserverForNameObjectQueueUsingBlock(
AVAudioSessionRouteChangeNotification,
null,
NSOperationQueue.mainQueue,
(notification: NSNotification) => {
const interuptionDict = notification.userInfo;
const routeChangeReason = interuptionDict.valueForKey(AVAudioSessionRouteChangeReasonKey);
if (routeChangeReason == AVAudioSessionRouteChangeReason.CategoryChange) {
const audioSession = AVAudioSession.sharedInstance();
try {
const success = audioSession.overrideOutputAudioPortError(
AVAudioSessionPortOverride.Speaker
);
if (success == false) {
console.log('Could not overrideOutputAudioPortError.');
}
} catch (error) {
console.log('Could not overrideOutputAudioPortError:', error);
}
}
});
const audioSession = ios.getter(
RTCAudioSession,
RTCAudioSession.sharedInstance
);
try {
audioSession.setCategoryWithOptionsError(
AVAudioSessionCategoryPlayAndRecord,
AVAudioSessionCategoryOptions.DefaultToSpeaker
);
} catch (e) {
console.log('MINSAMTALE: Could not toggle speaker:', e);
}
@triniwiz How can we change the audio output from the earpiece speaker to the main speaker. ?