Is it possible to manually (or using some scripting) put a file in the iphone documents folder and call it up using the WWW protocol.
How do I put the file in?
How do I get the path to the file?
Thanks,
Dan
Is it possible to manually (or using some scripting) put a file in the iphone documents folder and call it up using the WWW protocol.
How do I put the file in?
How do I get the path to the file?
Thanks,
Dan
Certainly.
You can get a path to a writeable directory like so:
string writeablePath = Application.dataPath.Substring(0, "/var/mobile/Applications/XXXXYYYY-XXXX-XXXX-XXXX-XXXXYYYYZZZZ/".Length) + "Documents/Raw";
Then you can use System.IO.Files to read and write the files in that directory:
System.IO.File.WriteAllBytes(writeablePath + "/mydocument.mp3", bytes);
byte[] mp3Bytes = System.IO.File.ReadAllBytes(writeablePath + "/mydocument.mp3");
And WWW:
WWW mp3WWW = new WWW("file://" + writeablePath + "/mydocument.mp3");
while (mp3WWW.isDone != true)
{
// Show progress or something.
yield return null;
}
if (mp3WWW.error == null)
{
byte[] mp3Bytes = mp3WWW.bytes;
// Do something cool.
}