11-30-2012 06:16 PM
ah, lucky you then ![]()
12-03-2012 10:39 AM
@Bulow: Either of those would be valid options.
@appcannon: I've seen WAV and MP3 files working in the past. I'm a bit surprised at the WAV failure, but I'd recommend giving it a shot with MP3s to see if that works. Otherwise without audio may be necessary while we look into the audio failing.
12-03-2012 11:02 AM
Yep, MP3s still didn't work.
All I'm doing is a simple implementation of HTML5 audio.
var audio = new Audio('audio.wav');
audio.play();
I have no idea why it doesn't work, but it does completely freeze up Webworks.
12-03-2012 04:14 PM
Here's a code sample that I use pretty often and have had success with.
var track = document.createElement('audio');
track.setAttribute('src', 'audio.mp3');
track.setAttribute('preload', 'auto');
track.setAttribute('loop', 'true');
track.setAttribute('autoplay', 'true');
track.load();
However, I would expect what you have to work just fine. Just to check, are you running that code after the DOMContentLoaded event? Example:
<!DOCTYPE html>
<html>
<head></head>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function () {
var audio = new Audio('audio.wav');
audio.play();
}, false);
</script>
</html>
Apologies if there are typos, I wrote that out in this reply window, but I think I got it right. Basically are you waiting until the DOM has completed loading before you attempt to create an Audio instance?
12-03-2012 06:15 PM
I'll try that. I've been running it via the jQuery
$(document).ready();
which I would assume runs off of the domcontentloaded event.
12-03-2012 06:21 PM
Right, jQuery's ready function should work just fine in that case.
12-03-2012 09:25 PM
Nope. Just tried the following, and Javascript still stopped.
$(document).ready(function(){
var track = document.createElement('audio');
track.setAttribute('src', 'sound/point.mp3');
track.setAttribute('preload', 'auto');
track.load();
track.play();
});Is there something that needs to be set in the config.xml to allow HTML5 audio or something?
12-04-2012 10:51 AM
Nope, HTML5 audio should just work out-of-the-box. Let me build/test a BAR file and I'll share it here once I've confirmed it working on my test device. Not that it should matter, but just to confirm, are you running a Dev Alpha A or Dev Alpha B?
12-04-2012 10:56 AM
I don't have a device period. I suppose it could be a simulator issue, and have nothing to do with Webworks.
12-04-2012 11:01 AM
I'll check on both in that case.