inway / flutter_ringtone_player

Simple Flutter plugin to play ringtone, alarm & notification sounds
MIT License
89 stars 57 forks source link

Custom ringtones from assets for Android and iOS. #33

Closed GeorgeAmgad closed 2 years ago

GeorgeAmgad commented 2 years ago

I added the ability to play ringtones from assets for both Android and iOS. If a platform specific ringtone is specified it will override the custom ringtone.

On Android: There was a painful problem with setting the asset as ringtone from the native side, so I created a temporary file in dart and accessed it from the native side. This is the same arcitecture AudioPlayers use for accessing assets, although I think it adds unwanted latency. On iOS: The asset is accessible from the native side so the soundID is easly generated.

On iOS I noticed in the documentation of sound system player that only .caf, .aif, or .wav are supported. However, I mistakenly tried with an .mp3 file and it worked in iPhone8 with iOS14, could someone furtherly test it so we can adjust the constrains? So far .mp3 and .wav are working so it could be published untill something comes up.

SPodjasek commented 2 years ago

@GeorgeAmgad Thanks a lot for your contribution. It will land in v3.2 soon - I'll try to fix & rebase #31 to ship them both.