0

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 !

Olivier
  • 18
  • 4

1 Answers1

2

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 :)

Tisho
  • 8,320
  • 6
  • 44
  • 52
Scrub5uk
  • 21
  • 2