Hello guys,
having a bit of a problem with video playback, using the Unity extension on an android device. I already solved the very same problem on the iOS platform, so I really hope, that there will be a way on android as well. Please allow me to tell you a bit more about my setup and what I'm trying to achieve.
So, I'm using both Vuforia AR and video playback plugin to enable augmented reality content on a mobile device. The videos I want to show, have to be downloaded at runtime, so I can't ship them inside the streaming assets folder. That would have been too easy :) Since the app also has many other (native) features, that I can't build (at least it would be very time consuming) inside Unity, I made Unity part of a regular android eclipse project. It took me some time to integrate Unity as a library, make sure trackers get recognized, etc..., but all that is 100% up and running. No issues there.
When I launch my app (Unity not yet running at that moment), it downloads the videos from my server and stores them inside a folder like that: /data/data/com.mycompany.myproject/files/videoassets/
The download works perfectly and the videos are actually located at that path (I checked). Now I fire up the Unity 3D part of my application and once a tracker image is recognized (that works too), I want it to load one of these videos.
My first approach was to use Application.persistentDataPath and then simply append the necessary subfolders, to finally rebuild the path mentioned above. I checked that in console and those paths match.
As you probably know, the vuforia video prefab by default needs a video file name set inside editor. Since I can't do that, because I don't know the video names in advance, I had to customize both VideoPlaybackBehaviour.cs and VideoPlayerHelper.cs. My modifications are minimal though. Maybe it's not too confusing, if I tell you, how I solved the problem for the iOS version of my app.
VideoPlaybackBehaviour has a variable named m_path. On iOS I manually set that path to the video I want to play back. The videos are located in a subfolder of my Documents folder: Documents/myvideos/
When I tried to use Application.persistentDataPath to hand it the exact path to my video, it wouldn't work either, but as soon as I handed it a path like: ../Documents/myvideos/myvideo.mp4 it started to work. Notice the ../ - that was crucial. Without that, no chance of getting the video to play. It appeared, as if I had to go one folder back (hence the ../), then go inside my Documents folder and take it from there.
Now, my problem is to find a similar solution on android as well. Long story short, I guess it comes down to this: The video playback plugin does not accept an exact path (using Application.persistentDataPath). It kinda wants something relative (at least my guess).
If you think my approach is way to complicated and there is an easier solution, please feel welcome to advice. All I want to do, is loading a video, that is not located inside the streaming assets folder, but inside a folder, I can write to at runtime.
Thanks in advance. Your help will be very much appreciated.
were you able to accomplish what you intended to do . if yes , could you please help me to achieve that ?