facebook

include mp3 files

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #338551 Reply

    FabioChen
    Member

    Hi,

    How would I go about including mp3 files in my ipa packages?

    Fabio

    #338552 Reply

    FabioChen
    Member

    Hi,

    I’ve managed to include mp3 files in the ipa/apk packages by using “Offline Support” setting “AppCache Support”.

    The audio works fine in web mode, but not in App mode…

    Here’s my code:

    
    
    function initAudio(audioId) {
    
       audio = new Audio();
       
       isPlaying = false;
       
       //stop audio when changing browser page or click home btn
       $(window).bind('pagehide',stopAudio); 
    }
      
    //start playing, update button label to STOP
    function playAudio(audioId) {
       audio.src = 'audio/' + audioId + '.mp3';
    
       if (!audio) return;
       buttonId = '#m1-wordlist-listItem-' + audioId;
       $(buttonId).click(audio.play());
    }
    

    Please advise.

    Fabio Chen

    #338627 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 3 posts - 1 through 3 (of 3 total)
Reply To: include mp3 files

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