Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Webworks sound button

I want to make a button which will respond with a sound when it is clicked. while a sound clip would work, I need a more robust solution so that it wont lag and is quick/responsive and can be press repeatedly (game-functioning style). What would be my best option?


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
Developer
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel

Re: Webworks sound button

try this

http://www.phon.ucl.ac.uk/home/mark/audio/play5.htm

http://answers.yahoo.com/question/index?qid=20100311224823AA9reIU
-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Webworks sound button

Depending on the BlackBerry device/OS you need this it could work using HTML5 audio. "Early" within your app you could create an audio element like this:

 

var audio = document.createElement('audio');
audio.src="audio/src.mp3";
audio.controls = false;

 

And within your buttons onclick you can call something like:

 

audio.play();

to play the audio file defined with the audio element.

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Webworks sound button

And, btw, there is an attribute that can be used for HTML5 media called "preload". On most mobile devices this isn't supported to not wasting bandwidth, but may be supported within an app. With it the audio will be buffered/cached on initialization of the HTML5 audio element. Give it a try using this with the source from my above post:

 

var audio = document.createElement('audio');
audio.src="audio/src.mp3";
audio.controls = false;
// try to pre-buffer/-load the audio source
audio.setAttribute("preload", "auto");

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Webworks sound button


BrajeshSanodiya wrote:
try this

http://www.phon.ucl.ac.uk/home/mark/audio/play5.htm

http://answers.yahoo.com/question/index?qid=20100311224823AA9reIU

solution 1 is not a html5 compliant solution

solution 2 will lag

 


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Webworks sound button


LBP wrote:

Depending on the BlackBerry device/OS you need this it could work using HTML5 audio. "Early" within your app you could create an audio element like this:

 

var audio = document.createElement('audio');
audio.src="audio/src.mp3";
audio.controls = false;

 

And within your buttons onclick you can call something like:

 

audio.play();

to play the audio file defined with the audio element.

 


I need a solution where I can do multiple pings. this seems like i need to load them up first. on phone os webworks this seems to be not an efficent solution. keep the ideas coming thoguh :smileyhappy:


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
Contributor
Posts: 22
Registered: ‎02-21-2012
My Device: Playbook torch 9800
My Carrier: Telus

Re: Webworks sound button

There are a few threads on this, here's mine:

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/audio-skips-stutters-second-time...

 

I found a solution that worked at the time, but with BB10 and webworks the custom api no longer works because of the switch to native code for the APIs. 

 

I've cobbled together a working solution for bb10 from bits and pieces on that thread, I will revisit it later.

 

Good luck.

 

 

 

Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Webworks sound button


ignites wrote:
I need a solution where I can do multiple pings. this seems like i need to load them up first. on phone os webworks this seems to be not an efficent solution. keep the ideas coming thoguh :smileyhappy:

I think it all depends on the encoding and therefore on the filesize of your audio. Since HTML5 media is embedded directly without any big framework or environment like Flash it might be faster in loading. For loading multiple pings/audio files you can use an object-array to store instances and when you need them you only need to call the audios[instance].play(); what makes it very easy I think.

 

BTW: it is also the best multi-platform solution for mobile devices since HTML5 media is almost everywhere where solutions like flash might not be supported in every case.

 

Without trying you will not be able to know about efficiency of such solutions.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.