Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

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

Guest
Jul 12, 2011 Jul 12, 2011

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.

TOPICS
Development
3.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jul 13, 2011 Jul 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

Translate
LEGEND ,
Jul 12, 2011 Jul 12, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 12, 2011 Jul 12, 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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 12, 2011 Jul 12, 2011

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

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

?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 13, 2011 Jul 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 13, 2011 Jul 13, 2011

yes, that is working.

thank you so much!

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 13, 2011 Jul 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 13, 2011 Jul 13, 2011

Hi Peter,

I think you are referring to  http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#applicationDirectory.

Sanika

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 13, 2011 Jul 13, 2011

Hi Sanika,

this was something closer to that paragraph for "nativePath":

Some Flex APIs, such as the source property of the SWFLoader class, use a URL (the url property of a File object), not a native path (the nativePath property).

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#nativePath

but that is not exactly what I've read (maybe that was A-blog or post on someone from A-team on his personal blog or post on stackoverflow).

(myself I'm using and providing solutions for paths using FILE protocol - file URI schemes - mostly whenever I can and where it is supported)

regards,

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 02, 2018 May 02, 2018

Can't for the life of me figure out why this doesnt work for me.  Gives me a StreamError on the  var mySound:Sound = newSound() line

var f:File = File.applicationStorageDirectory.resolvePath("/assets/music.mp3");

var resultUrl:String = f.url; // This works to load with a URLLoader

var resultPath:String = f.nativePath; // This works to load with a FileStream operation

trace(resultPath);

var req:URLRequest = new URLRequest(resultUrl);

var mySound:Sound = new Sound();

mySound.load(req);

mySound.play();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 02, 2018 May 02, 2018

The issue I believe is the file path to where iOS is storing these files.... has it changed?  Assets doesnt seem to work anymore.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 06, 2018 May 06, 2018
LATEST

As long as the assets folder was included when building the app, this seems to be working for me in another app:

var filepath:String = "assets/music.mp3";

var mySound:Sound = new Sound();

mySound.addEventListener(IOErrorEvent.IO_ERROR, onMusicError);

mySound.addEventListener(Event.COMPLETE, onMusicLoaded);

mySound.load(new URLRequest(filepath));

And then calling mySound.play() in the onMusicLoaded function.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines