Skip navigation
iden_tidad
Currently Being Moderated

Playing external sound (iOS app)

Aug 31, 2012 6:00 AM

Tags: #air #app #as3 #3.0 #ios #button #sound #action #3 #actionscript #code #as3.0 #random #ac3 #actionscript3 #ipa

Hi everyone, so I've got a problem, I am making some play btns that will play a sound when it's pressed,

I have the mp3 file in some folder that i refer to in the code:

it plays well when testing, but when i "publish" the app as an .ipa and put it in my iPhone the play button doesn't work,

and i added the folders to the app exactly as it is in the code, which is this:

 

 

Random_btn.addEventListener(MouseEvent.CLICK, playRandomSound);

 

var random_sound:Sound = new Sound();

random_sound.load(new URLRequest("random/randomness/randomsound.mp3"));

var my_randomchannel:SoundChannel = new SoundChannel();

 

function playRandomjSound(event:MouseEvent):void{

my_randomchannel = random_sound.play();

}

function stopSound(event:MouseEvent):void{

my_randomchannel.stop();

}

Any reason why it shouldn't play that i dont know?

I reapeat i added the "random" folder with the "randomness" sub folder with the "randomsound.mp3" file to the app in the AIR iOS settings..

 

Thanks for any responses to help

 
Replies
  • Currently Being Moderated
    Aug 31, 2012 9:26 AM   in reply to iden_tidad

    Try to use the File class to reference the file.

     

    var randFile:File = File.applicationDirectory.resolvePath("/random/randomness/randomsound .mp3");

     

    // exist?

    if (randFile.exists)

    {

         var random_sound:Sound = new Sound();

         random_sound.load(new URLRequest(randFile.nativePath));

     

         // etc

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 18, 2012 10:54 PM   in reply to sinious

    Thank you very much . I had the same problem, I tested with your code and works great.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 19, 2012 7:55 AM   in reply to l_avanti

    Glad it worked for you. It's a little weird at first but soon you'll appreciate properties like .url and .nativePath. Good luck to you both!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points