Search code examples
iosflashaudioairmp3

Air iOS,Flash Pro, external mp3 won't be played


My flash app has the following code. The sound is played when locally testing but it's not played when published on iOS.

The mp3 file is inside components/sound directory and the directory is included via Air iOS3.6 publish setting in Adobe Flash cs6 professional.

I did some testing and while the mp3 file and the directory exists(tested with File.exists) in iOS, sound.bytesLoaded shows 0 value. When testing locally, it shows actual file size.

Can anyone help me with this?

var path= File.applicationDirectory.resolvePath("components/sound/click.mp3").nativePath;
var sound = new Sound(new URLRequest(path));
sound.play();

[Edit]

It worked when I simply replaced new URLRequest(path) to new URLRequest("components/sound/click.mp3").

However, I would still appreciate if someone could explain why the former one(nativePath) didn't work.


Solution

  • Reading this thread on Adobe Community forums about loading external sounds on iOS, your code seems OK, the only suspicious thing I see is that you should begin the file path with "/", like:

    var path= File.applicationDirectory.resolvePath("/components/sound/click.mp3").nativePath;
    

    Hope this helps!