0

I am writing an extension for Firefox Mobile (Fennec) which should play a sound. Using nsISound, i.e.

var sound = ios.newURI(pathToSoundFile, null, null);
var player = Components.classes["@mozilla.org/sound;1"].createInstance(Components.interfaces.nsISound);
player.play(sound);

works fine on the Desktop version of Firefox, it but wouldn't produce any sound on FF Mobile. I also tried appending an audio element to the website,

var audioElement = win.content.document.createElement('audio');
audioElement.setAttribute('id','audio_test');
audioElement.setAttribute('src',pathToSoundFile);
win.content.document.body.appendChild(audioElement);
win.content.document.getElementById('audio_test').play();

which works, but only if the website is stored locally on my computer (due to security restrictions, I assume).

I tested this on an Asus Transformer Tablet with Android 4.2. Any suggestions?

1 Answers1

0

nsISound is not implemented on Fennec.

HTML5 audio should work with data URis. Read your audio file, base64-encode it and pass it as src e.g. "data:audio/ogg;base64," + base64encodeddata

paa
  • 5,048
  • 1
  • 18
  • 22