facebook

No Audio on iPhone

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 16 post (of 16 total)
  • Author
    Posts
  • #338628 Reply

    FabioChen
    Member

    Not sure how to implement audio with new Audio() therefore have gone with new Media() instead. Here’s the code:

    
    
    function onClickAudio(audioId) {
       buttonId = '#m1-wordlist-listItem-' + audioId;
       if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
         //CODE_FOR_IPHONE_||_IPAD
         var source= document.createElement('source'); 
         audio= document.createElement('audio'); 
         source.type='audio/mp3';
         source.src='audio/' + audioId + '.mp3'; 
    
         audio.setAttribute('src', source.src); 
       
       }else{
          //CODE_FOR_ANDROID
          audio = new Media("/android_asset/www/audio/" + audioId + ".mp3");
       }
       $(buttonId).click(audio.play());
    }
    
    

    (taken from http://jabbleashish.blogspot.com/2012/06/play-sound-in-iphone-phonegap.html)

    Fabio

Viewing 16 post (of 16 total)
Reply To: No Audio on iPhone

You must be logged in to post in the forum log in