Android Question Problem playing custom sound in Notification Builder Library

dieterp

Active Member
Licensed User
Longtime User
I am using the Notification Builder Library developed by @barx to handle the incoming notifications to my device. I am however having a problem with the CustomSound functionality. When I directly copy a 'notification.ogg' file to the 'Notifications' folder on my device, it works fine when I use the code Notification2.CustomSound = "file:///sdcard/notifications/notification.ogg"

However, when I copy the 'notification.ogg' file to the File.DirDefaultExternal folder, I cannot seem to play it from that folder. I've tried several paths (using file:///) but I just can't seem to get it to play. Will it not work from the File.DirDefaultExternal folder? I've posted the question in the Notification Builder forum, but @barx also doesn't seem to know if it would work or not. Anyone have any ideas for me?

Regards
 

dieterp

Active Member
Licensed User
Longtime User
It sounds like this is a problem that only affects guys called Dieter! I just ended up using the SoundPool library, so I play the notification file when the notification comes through

B4X:
Dim SP As SoundPool
Dim snd_file As Int

SP.Initialize(1)
   snd_file = SP.Load(File.DirAssets,"my_sound.ogg")
 
Upvote 0

Dieter Baumgartner

Member
Licensed User
Longtime User
Thank you very much, this works. Sometimes the easiest way is the best, but i was so fixed to get the Notification Builder custom sound running, that i didn't see the easy way !!
 
Upvote 0
Top