Quantcast
Viewing all articles
Browse latest Browse all 8068

Playing App Sourced Audio on Android

Hello, I am having great trouble getting Android to play audio files. They play fine on iOS.

I am adding a '/' to the start of file path but if I check that the file exists Android returns a false.

I have folder structure like so...

app->assets, controller, lib, migrations, models, styles, views

assets->alloy, android, audio, Background, blackberry, Icon, icons, images etc. etc.

Here is the code that attempts to play the audio...

var playAudio = document.getElementsByClassName('playAudio');
for (var i=0; i < playAudio.length; i++){
  //alert('I found the audio in the page and am adding an onClick event!');
  playAudio[i].addEventListener("click", function(e){
    var audioTags = document.getElementsByTagName('audio');
    for (var j=0; j < audioTags.length; j++){
      audioTags[j].play();
    }
  });
}
This is a javascript file that is working on the HTML document inside the app. This seems to work fine in iOS but not in Android. Can someone tell me what I am doing wrong?

Thank you.


Viewing all articles
Browse latest Browse all 8068

Trending Articles