-
Notifications
You must be signed in to change notification settings - Fork 160
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
request audio focus on android #149
base: master
Are you sure you want to change the base?
request audio focus on android #149
Conversation
tts engine doesn't request audio focus automatically on android, and tts.speak() starts speaking together with other audio app in parallel. I suggest to request audio focus beforehand, to stop other audio app (if ducking is turned off). |
P.S. In fact, I dislike the idea of existance of audiofocus management in this module at all. The audiofocus concept is more complicated than just "request/abandon", and proper audiofocus management may differ depending on application purpose |
thanks @PVoLan !
Yes, this is unwanted behaviour (in our case). At least in our app, it's ok to take audio focus forever, like any other audio app. If need to abandon focus after every utterance speaked - use ducking. If user needs to turn back his music from other audio app - he can go back to that audio app and resume the playback.
Initially I thought that request/abandon audiofocus could be also extracted to separate method of tts package, but probably it's not needed in most cases. I agree re option to NOT use audiofocus, it would be a nice further refinement. But in this pull request I've just made logic consistent for both android and iOS platform, because iOS takes audiofocus, and android doesn't. Overall, I would say that it would be nice to have both options: separate method for managing audiofocus manually, and parameter for using audiofocus in |
Yes. As any other system resource, it has to be released when your app has no more need in this resource. Sometimes it happens that OS can take focus away from you by force, but if this doesn't happen you'd better release it willingly.
No. The good practice is to request focus when you want to play music and abandon it after you've finished playing. This works both for long-time music and short-time sounds. |
In my app audiofocus is captured manually outside of react-native-tts module, and it worked fine before. If react-native-tts will also capture audiofocus, this can lead to struggle between two audiofocuses and bugs. It is ok for react-native-tts to capture audiofocus in some cases, but it should not be a default option. |
No description provided.