Can anyone tell me something about the filecache
I haven't found any detailed example code regarding the filecache.
So in what cases do I have to preload files Especially how is this preloading done Do I have to enter something in the manifest or playlist

filecache
Furty
Now I moved the file out of the aca and I am trying to load it like this:
-------------------------------------------------------------------
function
loadFragen() {var disc_filename = new String(file:///dvddisc/ADV_OBJ/questions.txt);
var fc_filename = new String(file:///filecache/questions.txt); var cbfnPreload = function(errorInfo) {
if (errorInfo == FileIO.SUCCEEDED) {
//ok
}else{
dbgOut("Errno: " + errorInfo);
}
};
FileIO.copy(disc_filename, fc_filename, true, cbfnPreload);
var cbfnLoadQuestions = function(textStream, errorInfo) {
dbgOut(String(errorInfo));
if (errorInfo == FileIO.SUCCEEDED) {
//do something
}else{
dbgOut("Errno: " + errorInfo );
}
};
FileIO.openTextFile(fc_filename, FileIO.FILE_IOMODE_READ, false, false, cbfnLoadQuestions);
}
-----------------------------------------------------------------------------
This doesn't work in iHDSim. I think I am still doing something wrong but can't see what ;)
edit: Sometimes I am getting error 3 (FILE_NOT_FOUND) and sometimes error 7 (ARGUMENT). I can't figure out the reason for what it is giving the varying errors.
Larry Surat
Most of the APIs and Markup elements that allow you to reference resources (such as images, sound files, other Markup files, etc.) require that those resources be present in the "File Cache" before they are used. The File Cache is divided into two areas:
var markupDoc = XMLParser.parse(file:///dvddisc/ADV_OBJ/templateMarkup.xmu, callback); // load initial markup document
// modify markupDoc using XML APIs
XMLParser.write(markupDoc, file:///filecache/realMarkup.xmu, XMLParser.UTF8, callback); // write markup file to file cache location so link() can use it
application.link(file:///filecache/realMarkup.xmu);
One more thing to keep in mind in the above example: it assumes that any images the markup files are using are also already in the File Cache. You would also need to copy them into a file:///filecache uri or reference them in your playlist in order for the link() to succeed.
dragoncells
CollegeSeniorProjectNeedsHelp
Tom Frey
The problem here is that you are copying the file and then trying to open it as a text file immediately... but it might not be copied yet. You need to delay your openTextFile until your callback from copy has returned.
Is there a reason why you're trying to copy this stuff rather than just load it as an application resource Note that if video is playing off the disc, you will fail with an INVALIDOPERATION anyway, since you can't copy files while playing video (the laser would have to jump).
Just put the original URI (file:///dvddisc/ADV_OBJ/question.txt) into your playlist and manifest. Then in your script you reference it by the same URI and it will magically be found in filecache automatically. Basically everytime you ask for something in script, it checks if there is already a copy in filecache before going to fetch it from the disc / persistent storage / network.
Thales Medeiros
so when I want to play a wav out of an aca I tried it like this:
var
cbfnPreload = function(errorInfo) {if (errorInfo == FileIO.SUCCEEDED) {
dbgOut("copied!");
}else{
dbgOut("Error copying File: Errno " + errorInfo);
}
};
Application.FileIO.copy("file:///dvddisc/ADV_OBJ/wer_wird_mrd.aca/wav_frage_RICHTIG.wav", "file:///filecache/wav_frage_RICHTIG.wav", true, cbfnPreload);
Unfortunately I get an Error number 3 (File not found). I checked it often the soundfile is definitively existing in the aca and the aca is named actually like this. Are there any additional things to consider when using aca files
chaza
Generally you don't need to use the FileIO routines to copy data from the disc -- especially during playback!
As long as the ACA is listed in the playlist file and the manifest as a resource to load, it will be loaded automatically into filecache. Then you refer to it with its original filename (eg, dvddisc/ADV_OBJ/ etc) and the player will know to use the copy in filecache.
Also, up until recently you were not allowed to copy files OUT of an ACA, but this has been clarified in a recent spec update. I don't think the version of iHDSim you have incorporates this new feature yet, which is why you would get the File Not Found. Even then, you might have to copy the whole ACA to filecache first and then extract individual files (I can't remember off the top of my head)
MarcGBeauchamp
So have you specified that the file should be copied into the filecache already by listing it in the playlist and manifest
If the file has already been copied to filecache from the disc, then when you try to copy from dvddisc to filecache it will get the alread-cached version and copy it to the API managed area.
The problem is still the timing issue -- you can't parse the file until your callback indicates that it has been copied correctly.