private void LoadFileToMemory(string folder, string filename) { #if !UNITY_WEBPLAYER string filePath = Path.Combine(folder, filename); // If we're running outside of the editor we may need to resolve the relative path // as the working-directory may not be that of the application EXE. if (!Application.isEditor && !Path.IsPathRooted(filePath)) { string rootPath = Path.GetFullPath(Path.Combine(Application.dataPath, "..")); filePath = Path.Combine(rootPath, filePath); } ReleaseMemoryFile(); if (File.Exists(filePath)) { byte[] bytes = System.IO.File.ReadAllBytes(filePath); if (bytes.Length > 0) { _bytesHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned); _moviePtr = _bytesHandle.AddrOfPinnedObject(); _movieLength = (uint)bytes.Length; _movie.LoadMovieFromMemory(true, filename, _moviePtr, _movieLength, FilterMode.Bilinear, TextureWrapMode.Clamp); } } #else Debug.LogError("[AVProWindowsMedia] Loading from memory not supported on this platform. Change platform to Standalone."); #endif }
private void LoadFileToMemory(string folder, string filename) { string filePath = Path.Combine(folder, filename); // If we're running outside of the editor we may need to resolve the relative path // as the working-directory may not be that of the application EXE. if (!Application.isEditor && !Path.IsPathRooted(filePath)) { string rootPath = Path.GetFullPath(Path.Combine(Application.dataPath, "..")); filePath = Path.Combine(rootPath, filePath); } ReleaseMemoryFile(); if (File.Exists(filePath)) { byte[] bytes = System.IO.File.ReadAllBytes(filePath); if (bytes.Length > 0) { _bytesHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned); _moviePtr = _bytesHandle.AddrOfPinnedObject(); _movieLength = (uint)bytes.Length; _movie.LoadMovieFromMemory(true, filename, _moviePtr, _movieLength); } } }