Android Question Play custom sound with NB6

FHEBERT

Member
Licensed User
Longtime User
Hello,
The demo NB6 works very well with the audio file "Shotgun.mp3", but something escapes me. Can not play another audio file. Even if I rename the file "shotgun.mp3" in "shotgun1.mp3" by declaring it of course in the file manager, it is not played. I have to name the audio files in "Shotgun.mp3"!
The reason must be obvious, but I do not see :-(

thank you so much
 

DonManfred

Expert
Licensed User
Longtime User
Can not play another audio file. Even if I rename the file "shotgun.mp3" in "shotgun1.mp3" by declaring it of course in the file manager, it is not played. I have to name the audio files in "Shotgun.mp3"!
1. You are missing a very important thing: Posting the code ou are using!
from the example code
B4X:
Sub Notification_WithCustomSound
    Dim rp As RuntimePermissions
    Dim folder As String = rp.GetSafeDirDefaultExternal("shared")
    Dim FileName As String = "shotgun.mp3"
    'copy the file to the shared folder
    File.Copy(File.DirAssets, FileName, folder, FileName)
    Dim n As NB6
    n.Initialize("custom sound", Application.LabelName, "DEFAULT")
    n.SmallIcon(LoadBitmapResize(File.DirAssets, "smiley.png", 32dip, 32dip, True))
    'disable the default sound
    n.SetDefaults(False, True, True)
    'set custom sound
    n.CustomSound(CreateFileProviderUri(folder, FileName))
    Dim Notification As Notification = n.Build("Notification with custom sound", "...", "", Me)
    Notification.Notify(3)
End Sub
 
Upvote 0

FHEBERT

Member
Licensed User
Longtime User
That's right !
This is the code.
If I rename this audio file by declaring it correctly in the file manager, I can not play it.
 
Upvote 0

FHEBERT

Member
Licensed User
Longtime User
I found my problem. Just read the initialization conditions.
The initialization of a notification is defined once and for all with its channel Id. It is necessary to uninstall the application to modify a parameter. Such as changing the audio file. Or initialize with a new Id channel.
This info may be useful for others.

upload_2019-1-6_18-23-33.png
 
Upvote 0
Top