03-05-2012 11:05 PM
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?
03-05-2012 11:09 PM
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.
03-05-2012 11:24 PM
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.
03-05-2012 11:30 PM
Send my your code and let me play with it - I can only test on os7 though.
03-06-2012 10:30 AM
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:
Here's an excerpt from that thread:
Thursday - last edited Thursday
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.