-
Notifications
You must be signed in to change notification settings - Fork 856
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
Add ability to play audio through notifications channel #19
Comments
Hi, @thirddimensionstudios , this is a very welcome addition, for sure. Makes a lot of sense to have that option. However, I'm not sure how to implement it; I was not even aware it was an option. I might study this soon to see how to, but the lib is nothing but a thin wrapper around the native APIs; so the relevant code would be put here and here. If you are acquainted with the native code, a PR is more than welcome. I can help with the dart wrapper if necessary (just add another parameter on the native end and we can add an optional parameter on Dart to match it). |
Thanks @luanpotter. For iOS I found this SO which may help (needs modernising to iOS11): https://stackoverflow.com/questions/28985942/best-method-to-play-an-short-audio-sound-on-ios-8-2 I'll have a play in the next few days but I've never coded in Obj-C so it will need checking over by someone capable! Java isn't a problem though. |
Adding this to the top of the togglePlay method in the iOS code seems to fix the issue BUT it retains the first file you ask it to play:
Really out of my depth here with Obj C - any idea why that might happen? |
@thirddimensionstudios trying to get this working... Have you tried to use this functionality using AudioPlayers on Android? |
@feroult I'm trying to get my hands on an Android device so that I can play around rather than just guess so not yet. I prefer using real devices for audio testing rather than simulators. |
Apple's Doc has a section "Checking Whether Other Audio Is Playing". |
I believe this would be fixed by using local notifications with a custom sound. In practice, Android and iOS only allow for 1 app to be playing sounds, however notifications with sound will play over them. |
Is this by any chance fixed by the new respectSilence flag? |
I believe this was fixed due to our recent PRs about respectSilence and notification handling. Please re-open if I'm mistaken. |
As of 0.13.7 (on iOs): respectSilence: true - sound is turned off as soon as the app goes into background. |
On iOS when playing music in the background from any other app (Spotify for example) the music stops when you play some audio through this plugin and it doesn't resume when finished.
When using this plugin as a music player that is absolutely fine but when using it to play motivational audio clips (similar to Strava's pace time updates etc) it doesn't really work since Spotify (in this case) will pause.
I come from a native Android developer background so the code is a little foreign to me but if there is such a thing as being able to treat the audio as a 'notification' instead of 'music' for iOS that would be a nice addition.
I understand this may not be the purpose this plugin was designed, just hoping you are open to the idea!
The text was updated successfully, but these errors were encountered: