Reputation: 161
var zip:FZip = new FZip();
zip.load(new URLRequest("xx.obb"));
this codes does not work. It throws "Unknown record signature:" error.
how did you extract .obb file ?
Upvotes: 1
Views: 6627
Reputation: 171
If your obb
file is like any other zip
file then you can treat it as such. First you will want a list of files to extract (could be all your files who knows).
Here is one way to get the files out :
private function obbFileUnpackingRoutine(event:Event):void{
addChild(obbUnpackScreen);
obbUnpackScreen.obbProgress.scaleX = zipCount/filesToUnpack.length;
setChildIndex(obbUnpackScreen, numChildren -1);
for (var i:uint = 0; i<24; i++){
if (zipCount == filesToUnpack.length){
zipDone = true;
removeEventListener(Event.ENTER_FRAME, obbFileUnpackingRoutine);
removeChild(obbUnpackScreen);
var fr:FileStream=new FileStream();
var str:String = File.applicationStorageDirectory.nativePath;
var cacheDir= new File(str +"/YourSettings");
fr.open(cacheDir.resolvePath("isObbUnpacked.pnr"),FileMode.WRITE);
fr.writeObject([zip.getFileCount(),zipCount]);
fr.close();
return
}
var file:FZipFile = zip.getFileByName(filesToUnpack[zipCount])
var cacheDir:File= null;
var str:String = File.applicationStorageDirectory.nativePath;
cacheDir= new File(str);
var fileContents = file.content
var fr:FileStream=new FileStream();
fr.open(cacheDir.resolvePath(file.filename),FileMode.WRITE);
fr.writeBytes(fileContents);
fr.close();
zipCount++;
}
}
If memory permits you may want to load your files directly from the zip file so you don't have to unpack them. Any file that can only accessed with a urlRequest will of course have to be extracted But you can load png files, mp3 files, and your own custom files with byteArrays
My obb file has thousands of tiny mp3 files and it can take upto 3 minutes to extract on an allWinner A10 processor. Direct loading means it can get the files instantly. And there is almost no delay at all.
Upvotes: 0
Reputation: 84
that way you need to read it? if it is to load a game I think it is a good way to load it so it would be better to load it from a specific route
for example: sdcard/android/obb/filename.obb
Upvotes: 0