nstudio / nativescript-camera-plus

MIT License
79 stars 50 forks source link

Audio low after using camera #162

Open swissdude opened 3 years ago

swissdude commented 3 years ago

I don't know whether this is really related to this plugin, but here's what I observed.

I have an app with a text2speech function. The camera is loaded into a modal view.

After opening and closing the camera, the text2speech is only half as loud as before. Setting the volume doesn't do anything.

Is the plugin fiddling with the volume settings? How can I avoid this?

The effect only shows on iOS - Android's working fine.

swissdude commented 3 years ago

I still don't know what the cause of the problem is, but if anyone runs into that, I just added

AVAudioSession.sharedInstance().setCategoryWithOptionsError( AVAudioSessionCategoryPlayAndRecord, AVAudioSessionCategoryOptions.DefaultToSpeaker);

before every audio-related task in the app. That seems to reset the volume.

The problem applies to videos that are played as well, btw. So after showing the camera-preview to the user, the volume of all other sounds is dropped to like 10%.

Bezlepkin commented 3 years ago

I still don't know what the cause of the problem is, but if anyone runs into that, I just added

AVAudioSession.sharedInstance().setCategoryWithOptionsError( AVAudioSessionCategoryPlayAndRecord, AVAudioSessionCategoryOptions.DefaultToSpeaker);

before every audio-related task in the app. That seems to reset the volume.

The problem applies to videos that are played as well, btw. So after showing the camera-preview to the user, the volume of all other sounds is dropped to like 10%.

Hi! Have you solved this problem?

update-switzerland commented 3 years ago

@Bezlepkin Didn't really solve it - just what I wrote above your comment. Add AVAudioSession.sharedInstance().setCategoryWithOptionsError( AVAudioSessionCategoryPlayAndRecord, AVAudioSessionCategoryOptions.DefaultToSpeaker); to every Audio related task. That should reset the volume.