02-07-2012 04:25 PM
Hi
Just spent a few hours downloading and setting up smartphone (version 7) simulators and PlayBook simulator with VMWare.
DOwnloaded KitchenSink app showcasing html5 webworks - built this and ran on PB and BB (.cod and .bar files) deployed, after several attempts.
However, I cannot find a way to play a sound file (mp3, wav or anything else) in Ripple, simulator or real devices.
Can someone post the appropriate javascript code (with webworks or native support) to play an audio file on click of a hyperlink.
I don't want to show natie html5 (browser control) - I want to add an eventListener or call a javascript function to run the audio when the user clicks/taps a link.
This is the last thing I need to do to get my mini app working on pb.
thanks.
02-07-2012 04:36 PM
Found some posts stating problems with simulator - ok, thats fine, but this still doesn't work on a real device either, once I've packaged and deployed. Snippit of sample javascript anyone?
cheers
02-07-2012 08:17 PM
I put test code/sample in when answering http://supportforums.blackberry.com/t5/Web-and-Web
02-08-2012 10:42 AM
The simplest way I've found is to set up the HTML5 audio tag:
<audio preload="auto" autobuffer id="audio"> <source src="audio/1.wav"> </audio>
Then put this in any HTML tag (a, img, div, etc.):
onclick="document.getElementById('audio').play()"
This will pre-buffer the audio file with no controls, and then clicking your link, image, whatever will start it playing. There is also a .pause() function to stop playback if that's required.
03-16-2012 06:03 PM
That works but on the Playbook, it pauses any other music you have on. Any way to keep it separate?
03-19-2012 03:36 PM
Unfortunately no, HTML5 audio currently supports single audio channel on PlayBook. If you start playing a second audio file, you can expect the first to be stopped. The BrowserDev team is working on expanding this (no ETA).
Understand that single channel audio restricts ability to provide certain features (e.g. background music + foreground sound effects), however it is what it is today, but will improve with a future build.
Flash does allow you to play multiple audio files, and we have an extension published as part of a WebGL-sample. You can see and download the code here if interested to enable this capability in your WebWOrks apps:
https://github.com/blackberry/WebGL-Samples/tree/m
03-28-2012 10:36 PM
Hi astanley,
Thanks for your feedback. I finally had time to experiment and I was able to play audio using the WebGL sample (using blackberry.custom.audio). Great workaround! Just one problem now: it works fine in the playbook but if the exact same code causes my javascript loop to stop in Ripple. In other words, either Ripple did not see that the "blackberry.custom.audio" extension was added into the "ext" folder or it needs to be refreshed? I can't figure out how to do that... Please help!
03-28-2012 10:50 PM
On second thought.... .I just tested the tunneltilt app in Ripple and that doesn't work either. I guess Ripple is still somewhat limited