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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Trusted Contributor
Posts: 119
Registered: ‎11-28-2011
My Device: 9930
My Carrier: Verizon

Re: Audio HTML5 Autoplay WebWorks or play on click

To play a song, are you opening a new web page and then executing the function when that new page opens?

In order to play another song when one is playing, does your user need to close the active page, make a selection on another page, and then have the new page open? 

 

Highlighted
Contributor
Posts: 28
Registered: ‎07-19-2011
My Device: 9800 and Playbook
My Carrier: Telus

Re: Audio HTML5 Autoplay WebWorks or play on click

I've defined mine inside the function but you could define it well outside (kind of like a class level variable from c# or php, or vb) and then check if the song is playing. Then you could stop it, change src, load the long (audioElement.load) - wait for the loaded fire and hit play.

 

I think that should work.

Trusted Contributor
Posts: 119
Registered: ‎11-28-2011
My Device: 9930
My Carrier: Verizon

Re: Audio HTML5 Autoplay WebWorks or play on click

If you defined your audio element inside the function, I don't see how you were able to stop an audio element that's currently playing and then play another copy of that element. In other words, I don't see how you're able to avoid multiple streams playing at the same time, which is what happened to me when I tried your implementation.

 

In my original program, I used a global audio variable in javascript. I switched streams by changing the audio element's src. This worked brilliantly in Chrome, brilliantly in Ripple.  But when it came time for a test on an actual piece of hardware, when I tried to switch from one stream to another, the first stream stopped playing and the second streamm (apparently) buffers and I hear nothing. If I close the app and reopen, same behavior. Thus, I have been pulling my hair out.

Contributor
Posts: 28
Registered: ‎07-19-2011
My Device: 9800 and Playbook
My Carrier: Telus

Re: Audio HTML5 Autoplay WebWorks or play on click

Send my your code and let me play with it - I can only test on os7 though.

Trusted Contributor
Posts: 119
Registered: ‎11-28-2011
My Device: 9930
My Carrier: Verizon

Re: Audio HTML5 Autoplay WebWorks or play on click

I was able to have a testor run the code on os7, and when the code is switching to new stream, instead of no audio, the entire app just crashes. Thanks for your offer to look at my code. I've actually already raised my issue in a different thread, along with the different things I've uncovered as I dug into the problem:

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/HTML5-Audio-Does-not-Play-when-S...

 

Here's an excerpt from that thread:

 

Re: HTML5 Audio Does not Play when SRC is Switched [ Edited ]

Here's my code:

 

 

//global audio variable here

var audio = new Audio;

audio.setAttribute("autoplay","autoplay");

//Then within an function in the same jscipt file, I set the url. It's                  

//when this runs a second time with a different url that it stalls.

audio.pause();

audio.setAttribute("src", "");

audio.setAttribute("src", result.rows.item(q).url_);

audio.load();

 

 

Can anybody help? I can't really go forward unless I can get past this problem.