Skip to main content
Participant
January 31, 2012
Question

Save video in applicationStorageDirectory on iOS

  • January 31, 2012
  • 1 reply
  • 1947 views

Hello !

I would like to save a video into the applicationStorageDirectory of my iPad. The code I have works well, but on iPad, it doesn't work, it sends me an MediaErrorEvent with an errorid 16. I think that this is due to an access problem, but it's weird because i succeed to write in the .flv file.

I save the urlStream into a file:

// get bytes

fileData = new ByteArray();

urlStream.readBytes(fileData, 0, urlStream.bytesAvailable);

// saving

var file : File = File.applicationStorageDirectory.resolvePath(FILE_NAME);

var fileStream : FileStream = new FileStream();

fileStream.open(file, FileMode.WRITE);

fileStream.writeBytes(fileData);

fileStream.close();

This works well, I have been able to watch the flv video in an jailbroken iPad.

But when I want to play my video with OSMF:

var file : File = File.applicationStorageDirectory.resolvePath(FILE_NAME);

var netLoader : NetLoader = new NetLoader();

var media : VideoElement = new VideoElement(new URLResource(file.nativePath), netLoader);

mediaPlayer = new MediaPlayer(media);

mediaPlayer.addEventListener(LoadEvent.BYTES_TOTAL_CHANGE, appendText);

mediaPlayer.addEventListener(MediaErrorEvent.MEDIA_ERROR, appendText);

var display : MediaContainer = new MediaContainer();

it sends me an error with errorid 16.

Any idea ?

Thanks !

This topic has been closed for replies.

1 reply

May 14, 2012

Hey, Have you found a solution ? I got the same problem...

Tkx

sinious
Legend
May 14, 2012

Have you tried loading the .url property?

e.g.:

var media:VideoElement = new VideoElement(new URLResource(file.url), netLoader);

July 12, 2012

Not sure if this'll work for you, but I've found that if I do something like:

var _url:String = File.applicationStorageDirectory.resolvePath(FILE_NAME).nativePath;

_url = "file:///" + _url;

 

then construct the element based on:

var _resource:URLResource = new new URLResource(_url);

OSMF seems to be able to recognise the file.

Hope that helps