Skip to main content
July 13, 2011
Answered

IOS: (not) playing sound from local file system - Error #2032

  • July 13, 2011
  • 2 replies
  • 3809 views

Dear all,

I am working on an app where I want to (among others) play sound files from the local file system.

I have added a few mp3 files into my .ipa file.

With a small file browser in my app I can select any one of them which returns me a File object.

I then use this File object to do a URLRequest to load the sound:

var req:URLRequest = new URLRequest(file.nativePath);

sound = new Sound();

sound.addEventListener(IOErrorEvent.IO_ERROR, soundLoadError);
sound.addEventListener(Event.COMPLETE, soundLoaded);
sound.load(req);

It works in flash, but fails on the iPAD. Everytime I try to load, I get a IOErrorEvent with error code Error #2032

When I replace new URLRequest(file.nativePath) with URLRequest("http://.../testfile.mp3"), everything works fine!

Any help appreciated.

Is this a matter of Security settings? Can I change those?

Something to do with Sandboxing (whatever that is)?

or something to do with cross-domain access?

I have been looking around for days now and any help would be appreciated!

I am using Flash CS5.5 & AIR 2.7

Thanks, Marcus.

This topic has been closed for replies.
Correct answer blazejewicz

Hi Marcus,

can you try (or maybe have you tried):

var path:String = file.url;

var req:URLRequest = new URLRequest(path);

?

regards,

Peter

2 replies

blazejewiczCorrect answer
Participating Frequently
July 13, 2011

Hi Marcus,

can you try (or maybe have you tried):

var path:String = file.url;

var req:URLRequest = new URLRequest(path);

?

regards,

Peter

July 13, 2011

yes, that is working.

thank you so much!

var req:URLRequest = new URLRequest(file.url);

Participating Frequently
July 13, 2011

Hi Marcus,

OK, that's buried somewhere in flash.filesystem.File docs: some api and components in Flash/Air runtime details do require URI/URL *not* native path

(I cannot find specific paragraph right now but I"m sure I've read that in Adobe's docs),

regards,

Peter

Colin Holgate
Inspiring
July 13, 2011

Did you add the sound file in your iOS settings, under the General tab?

July 13, 2011

Yes, the files were added under the general tab.

In my application, I have a custom browser showing me all my files in my application path. It looks something like this:

[ META-INF ]

[ ...CodeSIgnature ]

[ cs.lproj ]

[ de.proj ]

(etc)

testsound1.mp3 (<- the included mp3 files)

testsound2.mp3

testsound3.mp3

CodeResources

AppIcon.png

(etc)

July 13, 2011

maybe it's not allowed to read from the path:

/var/mobile/Applications/6206ED19-1875-B70B-B41AFF5BDA3D/Main.app/music/TranceOne.mp3

?