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.

A few questions:

1. What does your manifest look like?

2. Where did you put your audio file?

Thanks!
_______________________________________________
dev-b2g mailing list
dev-b2g@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to