问题
I am in the midst of making some prototypes that require me to play large video files from a unity application (10gb+). These are 360 videos that will be played in a hospital environment and therefore I am hard pressed to simply upload these videos to a server as I am doing now and streaming them. The Hospital does not allow downloads like these and the connection is not good enough to stream it effectively.
My solution to this is to add the videos to the headset manually and then simply play them from the unity application by fetching them by code as I will know where they are stored. Alas, I cannot seem to get this to work.
I have attempted to put the videos in the streaming assets folder but unity cannot even build when trying this as I get java heap space problems I have furthermore added the permissions to the Android manifest so it should have permission to fetch the video.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
I am wondering if there is anyone that has experience with this sort of thing that would kindly shed some light on how to go about placing a video file locally in the headset (most likely in the com.< companyname>.< applicationname> folder or "persistent path" ) and then playing it from script or from the videoplayer Url/Path.
thanks kindly. Unity 2019.2 0b1
回答1:
Having your Videos in StreamingAssets won't work for certain file sizes on Android. So what I do with my Oculus Go MediaPlayer is to put all Videos into a folder on my Headset and then load them with an absolute path. In Unity you can fetch the android rootpath like this:
rootPath = Application.persistentDataPath.Substring(0, Application.persistentDataPath.IndexOf("Android", StringComparison.Ordinal));
And from there on just add the path of your own created folder, for example like this:
string path = Path.Combine(Path.Combine(rootPath, "ExampleFolder/ExampleSubdirectory"), FileName);
来源:https://stackoverflow.com/questions/56437328/retrieving-and-playing-a-video-file-stored-locally-on-an-android-vr-headset-ocu