Android Question SoundPool StreamType


Active Member
Licensed User
i need to play custom notification sound

Notification builder only support sounds from the external dir which requires writing to sdcard permission and its not suitable for my app

also i tried to load the sound from resources
nb.CustomSound= "android.resource://b4a.example/R.raw.notf"
but it didn't work too

so i decided to use SoundPool to play the notification sound but unfortunately the streamType is hardcoded to STREAM_MUSIC (users always set media volume low)
is it possible to set it to STREAM_NOTIFICATION

thanks in advance


Licensed User
Try this:
Dim SPJO As JavaObject
        SP = SPJO

Dim Soundpool as Normal, instead of initializing it run the code above and assign it to your Soundpool variable (SP in this case).

4 is the maxstreams value
5 is the Streamtype
0 is srcQuality which actually does nothing.

See, int, int) for more info.

If you are targeting an API > 21, you may want to try the Soundpool builder instead.

StreamTypes constants can be found here:
Upvote 0