1

I am writing a Chrome Web Application in which I am dynamically creating <audio> tags through Javascript. Javascript is pulling the names from an object literal. When I run the files locally through Chrome, it works just fine. Once I load them onto a server, they stop working. The dynamic images work fine, so I'm curious as to why the audio does not. What could possibly be wrong? Here is my javascript code:

var IG = {
  0: { 'sound': 'chair.ogg', 'link': 'images/chair.png', 'name': 'Chair'}
};

var audio1 = '<audio controls><source src="audio"';
var audio2 = '" type="audio/ogg">Your browser does not support the audio element.       Please upgrade your browser.</audio>';

document.getElementById('quiz').innerHTML += audio1 + IG[order].sound + audio2;

UPDATE: If I play the sound file directly, it works fine. Eg: www.site.com/audio/chair.ogg. I have also tried using mp3 files with the same result.

Willow
  • 1,040
  • 2
  • 10
  • 21
  • Did you checked that your support these file format? –  Mar 24 '13 at 08:50
  • You have to make sure your ogg file loade. If you run it locally then its load quite rapidly than server. This is issue –  Mar 24 '13 at 08:56
  • Is your server actually serving you the file. It may not be configured to serve ogg. – kevmc Mar 24 '13 at 09:34
  • Has to do with the response headers. Local file works because it doesn't have response headers. – HMR Mar 24 '13 at 09:36
  • http://stackoverflow.com/questions/8831625/html5-audio-not-working-on-firefox/9203835#9203835 – HMR Mar 24 '13 at 09:40

1 Answers1

0

I found the solution. I simply put a " where I needed to put a /

src="audio"';

needed to be:

src="audio/';
Willow
  • 1,040
  • 2
  • 10
  • 21