B4J Question [ABMaterial] sound during an event

MichalK73

Well-Known Member
Licensed User
Longtime User
I would like during the event, for example press the button to the user heard the sound. ABMAudioPlayer does not have a background sound. Can you do it?
 

Philip Chatzigeorgiadis

Active Member
Licensed User
Longtime User
I would like during the event, for example press the button to the user heard the sound. ABMAudioPlayer does not have a background sound. Can you do it?

This is how I play a sound when an ABMButton is clicked:

Step1 : Copy the attached playsound.js file to folder www/js/custom/

Step2: In the www/YourAppName/ folder, create a folder named Audio. Copy your sound file (e.g. YourSound.mp3) to this www/YourAppName/Audio/ folder.

Step3: In the BuildPage sub, add after the Page.BuildGrid command this code:
B4X:
page.AddExtraJavaScriptFile("custom/playsound.js")

Step4: In your btn_clicked sub, add this code:
B4X:
Dim args As List
args.Initialize
args.Add("../Audio/YourSound.mp3")
page.ws.RunFunction("playsound",args)
 

Attachments

  • playsound.zip
    212 bytes · Views: 319
Upvote 0
Top