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
Trusted Contributor
mobilvar
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? 

 

Please use plain text.
Contributor
nomi34
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.

Please use plain text.
Trusted Contributor
mobilvar
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.

Please use plain text.
Contributor
nomi34
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.

Please use plain text.
Trusted Contributor
mobilvar
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.

Please use plain text.