Unable to acess video file inside my apk from unity
Greetings,
I am developing an android application, and i need to access a video file (.mp4) which is located inside the apk.
Basically I have native C program that utilize FFMPEG to take a video file , open it, decode it and extract all the frames from it. I have already confirmed the operation of this code. However the code will not work without a proper video file location being passed in to it in the first place.
I have placed my (.mp4) file inside Assets\StreamingAssets folder and I build the apk using unity.
I have followed the instructions on the unity streamingAssets manual https://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html but I have not be able to achieve the expected results.
Basically the
filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "video.mp4");
Will return the location of the video correctly
"jar:file:///:.................................!/assets/video.mp4";
but once i pass this string into my C function, the C function that opens the video stream does not operate.
This was not a problem when I provided the location of the file from a windows platform, but when I provide the location from within the apk, it simply doesn't work.
My guess is that since the apk is compressed jar file then I must somehow decompress it before i can get access to the video location properly. is it correct to assume that the WWW object will do the decompressing ? I read the unity Manuel on the WWW class and it doesn't say anything about being able to decompress a .jar file.
I have also read these forms http://answers.unity3d.com/questions/210909/android-streamingassets-file-access.html
http://stackoverflow.com/questions/8246917/how-to-access-unity-assets-natively-on-android-or-iphone
Here is my current code
[DllImport("libnative-lib")]
static extern int DecoderFunction(string filename);
.
.
.
.
.
void Start()
{
filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "Italy2.mp4");
WWW www = new WWW(filePath);
while (!www.isDone) {}
// Decoding the video into frames
Num = DecoderFunction(www.text); // This function is implemented in C
}
My native C code is compiled into (.so file which is a dynamically linked file for android platforms). Is it even possible to have the native C code access a directory which is located inside an apk?
I just need guidance in the right direction.
Thank you all.
Your answer
Follow this Question
Related Questions
Unity can not access StreamingAssets on IOS 1 Answer
Failed to re-package resources 0 Answers
CommandInvocationFailed 1 Answer
Keep a file from assets after build 0 Answers