void INatShare.GetThumbnail(string videoPath, Action <Texture2D> callback, float time) { IntPtr[] thumbnailData = new IntPtr[3]; int unused = 0; var thumbnailHandle = GCHandle.Alloc(thumbnailData, GCHandleType.Pinned); NatShareBridge.GetThumbnail(videoPath, time, ref thumbnailData[0], ref unused, ref unused); var callbackObject = new GameObject("NatShareWebGL Delegate").AddComponent <ThumbnailDelegate>(); callbackObject.StartCoroutine(GetThumbnail(thumbnailHandle, callback, callbackObject)); }
void INatShare.GetThumbnail(string videoPath, Action <Texture2D> callback, float time) { IntPtr pixelBuffer = IntPtr.Zero; int width = 0, height = 0; if (!NatShareBridge.GetThumbnail(videoPath, time, ref pixelBuffer, ref width, ref height)) { Debug.LogError("NatShare Error: Failed to get thumbnail for video at path: " + videoPath); callback(null); } var thumbnail = new Texture2D(width, height, TextureFormat.BGRA32, false); thumbnail.LoadRawTextureData(pixelBuffer, width * height * 4); thumbnail.Apply(); NatShareBridge.FreeThumbnail(pixelBuffer); callback(thumbnail); }