Page 1 of 1

How do I add audio to a button?

Posted: Thu Jan 23, 2014 12:13 pm
by Mark Gibbons

Hi there; I'm unfamiliar with any code or HTML5 but trying to learn, and as of writing this I'm only 3 hours into it so I sincerely apologise for being out of touch or asking a stupid question.

I simply want to create an app, that's just the home screen with a button, when you push the button it plays a sound effect. (I have a 0.3MB, 2 second .mp3 file that I want to use for it.) And that's basically my app.

I cannot figure out how to add an .mp3 to a button, or even the music tab that is offered.

Any help, in simpleton speak for now would be greatly appreciated. (Along with any advice for a complete beginner). Also as some feedback to any staff: It was amazingly simple to upload and add the image from my computer, if uploading small sound files to segments was similar, that would really speed things up.

Image


How do I add audio to a button?

Posted: Thu Jan 23, 2014 2:10 pm
by Kateryna Grynko

Hi Mark,

You can specify a link to an mp3 file in properties panel:
http://docs.appery.io/documentation/u...

You can also set its URL dynamically: preAppery("mobileaudio").attr("src", "http://example.com/1.mp3");/pre
Where mobileaudio is a name of Audio component and http://example.com/1.mp3 is a link to mp3 file.


How do I add audio to a button?

Posted: Wed Jun 18, 2014 3:30 pm
by Rom

Thanks Katya,

I had a similar question and your answer did help me to some extent.
Could you please also brief how can I access a stored variable and play using a URL stored in variable?

I'm using the below code:

var url = localStorage.getItem("songDirectLink");
alert(url);
Appery("audioPlayer").attr("src", "url");
Appery("audioPlayer").trigger("play");

The alert, which I just created to test the variable and it's value gives right URL that I want player to play. However, player doesn't load the remote file, but if I manually insert URL instead of var "url", player works fine.

Please help!


How do I add audio to a button?

Posted: Wed Jun 18, 2014 7:34 pm
by Kateryna Grynko

Hi Rom,

You pass a string "url" rather than a variable to Audio component, so replace:preAppery("audioPlayer").attr("src", "url");/preWith:preAppery("audioPlayer").attr("src", url);/pre