I got this to work on my keon by putting it in its own script with code like:
function processMyAudio() {
console.log("audio loaded");
// Stop the audio temporarily
myAudio.pause();
// Sets the position to play from.
//myAudio.currentTime = 1;
// How long is the audio?
console.log(myAudio.duration);
// Play the audio.
myAudio.play();
}
console.log("page loaded");
// Create audio object.
myAudio = new Audio("song.wav");
myAudio.oncanplaythrough = processMyAudio;
----- Original Message -----
From: "Bob Thulfram" <[email protected]>
To: [email protected]
Sent: Monday, December 9, 2013 11:49:39 PM
Subject: Re: [b2g] Need simple help with audio
On Monday, December 9, 2013 6:49:07 PM UTC-8, Bob Thulfram wrote:
> Or maybe audio isn't simple anymore. All I want to do is play an audio file.
>
>
>
> Here's my code:
>
>
>
> <!DOCTYPE HTML>
>
> <html>
>
> <head>
>
> <meta charset="utf-8">
>
> <title>
>
> Audio Test
>
> </title>
>
>
>
> <script>
>
>
>
> // Load the page.
>
> window.addEventListener("load",
>
> runFirst, false);
>
>
>
>
>
> // Runs when the page is loaded.
>
> function runFirst() {
>
>
>
> console.log("page loaded");
>
>
>
> // Create audio object.
>
> myAudio = document.createElement("audio");
>
> myAudio.src = "oggsong.ogg";
>
> myAudio.src = "mp3song.mp3";
>
> myBody.appendChild(myAudio);
>
>
>
> // What did we load?
>
> console.log(myAudio.src);
>
>
>
> // Wait until we can play.
>
> myAudio.addEventListener("canplay",
>
> processAudio, false);
>
> }
>
>
>
> // Called when audio is ready to play.
>
> function processAudio() {
>
>
>
> // Stop the event firing.
>
> myAudio.removeEventListener("canplay", processAudio);
>
>
>
> console.log("audio loaded");
>
>
>
> // Stop the audio temporarily
>
> myAudio.pause();
>
>
>
> // Sets the position to play from.
>
> myAudio.currentTime = 10;
>
>
>
> // How long is the audio?
>
> console.log(myAudio.duration);
>
>
>
> // Play the audio.
>
> myAudio.play();
>
>
>
> }
>
>
>
> </script>
>
> </head>
>
>
>
> <body id="myBody">
>
> </body>
>
>
>
> </html>
>
>
>
> This plays the song in Firefox 27, IE 11, and Chrome #whocares. But when I
> put it on my ZTE Open, no sound.
>
>
>
> Here's my manifest:
>
>
>
> {
>
> "name": "Little Audio",
>
> "description": "Playing audio",
>
> "launch_path": "/index.html",
>
> "icons": {
>
> "60": "/icons/icon-60.png",
>
> "128": "/icons/icon-128.png"
>
> },
>
> "developer": {
>
> "name": "Your Name",
>
> "url": "http://www.yourwebsite.com"
>
> },
>
> "default_locale": "en"
>
> }
>
>
>
> I have two questions:
>
>
>
> 1. What am I doing wrong? Is the manifest wrong? Do I need to specify the
> music loaded in the manifest. The music is in the same folder level as
> index.com.
>
>
>
> 2. I've noticed that the ogg file doesn't load in Firefox. Is Firefox now
> supporting MP3? I put the ogg file first, thinking that Firefox might like
> it, but maybe it doesn't love ogg any longer?
>
>
>
> I'm loading this onto the phone through the USB cable, so it should have the
> permissions. Any clues would be great. This is frustrating because it works
> on all the other browsers. Thanks!
>
>
>
> PS: I know WebAudio is better, but I'd like to get HTML5 Audio working on
> Firefox OS. I'll write about it in my blog if I can get some clues.
Another question: when I load the app into my phone via USB, where does the
audio file go? What folder is it in?
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g