Play a sound, updated with working method

2
Hi there, I've been searching on the forum about how to try to let mendix play a sound file. I have succeeded and updated this question to remove unnecessary information. Sorry for the upbumping in the forum! 2. Apparently people are able to make java actions to play the audio file: https://forum.mendix.com/link/questions/5761 3. Custom widget: https://forum.mendix.com/link/questions/20342  4. HTML snippet --> Method I used  ---------------------------------------Solution: HTML snippet where I call the audio file I placed into the Theme folder (PC) or into the phonegap package in the www folder. (Do it yourself package, unzip phonegap, go to dist folder, unzip the phonegap there, place the audio into the www folder, and rezip. Use this to build the apk)   I used two instances of HTML snippet (with context):  Configure the first as Content Type = HTML: <audio autoplay id="my_audio"> <source src="audiofile.wav" type="audio/wav"> </audio> Configure the second as Content Type = JavaScript with jQuery: $(document).ready(function() {  setTimeout(function() { $(document).ready(function() {                  $("#my_audio").get(0).play(); }); }, 600); }); The timeout was necessary for me to have the sound play after the page is loaded. Thank you Dragos and Mark! Had to mark one as answer but I used Mark's HTML and Dragos file location method :)
asked
2 answers
3

Hello Desiree,

If you use the web player you'd have to place your sound file somewhere within the "theme" folder within your project. I believe that is your base directory for any relative paths you use.

Hope this helps

answered
1

Perhaps not the best answer, but I used CustomString (https://appstore.home.mendix.com/link/app/1426/) to put some HTML onto the page.

The string was  '<audio controls autoplay preload> <source src="' + {construct your filename here} + '" type="audio/mp3"> </audio>'

 

answered