public void GetThumbnail (string path, Action<Texture2D> callback, float time) {
     IntPtr[] thumbnailData = new IntPtr[3]; int unused = 0;
     var thumbnailHandle = GCHandle.Alloc(thumbnailData, GCHandleType.Pinned);
     SharingBridge.GetThumbnail(path, time, ref thumbnailData[0], ref unused, ref unused);
     var callbackObject = new GameObject("NatCorderWebGL Delegate").AddComponent<VideoDelegate>();
     callbackObject.StartCoroutine(GetThumbnail(thumbnailHandle, callback, callbackObject));
 }
 private IEnumerator GetThumbnail (GCHandle thumbnailHandle, Action<Texture2D> callback, VideoDelegate callbackObject) {
     yield return new WaitUntil(() => Marshal.ReadIntPtr(thumbnailHandle.AddrOfPinnedObject()) != IntPtr.Zero);
     MonoBehaviour.Destroy(callbackObject); // We don't need this anymore
     var pixelBuffer = Marshal.ReadIntPtr(thumbnailHandle.AddrOfPinnedObject());
     var width = Marshal.ReadInt32(new IntPtr(thumbnailHandle.AddrOfPinnedObject().ToInt32() + sizeof(int)));
     var height = Marshal.ReadInt32(new IntPtr(thumbnailHandle.AddrOfPinnedObject().ToInt32() + 2 * sizeof(int)));
     var thumbnail = new Texture2D(width, height, TextureFormat.RGBA32, false);
     thumbnail.LoadRawTextureData(pixelBuffer, width * height * 4);
     thumbnail.Apply();
     SharingBridge.FreeThumbnail(thumbnailHandle.AddrOfPinnedObject());
     thumbnailHandle.Free();
     callback(thumbnail);
 }
        public void GetThumbnail(string path, Action <Texture2D> callback, float time)
        {
            IntPtr pixelBuffer = IntPtr.Zero; int width = 0, height = 0;

            if (!SharingBridge.GetThumbnail(path, time, ref pixelBuffer, ref width, ref height))
            {
                Debug.LogError("NatCorder Error: Failed to get thumbnail for video at path: " + path);
                callback(null);
            }
            var thumbnail = new Texture2D(width, height, TextureFormat.BGRA32, false);

            thumbnail.LoadRawTextureData(pixelBuffer, width * height * 4);
            thumbnail.Apply();
            SharingBridge.FreeThumbnail(pixelBuffer);
            callback(thumbnail);
        }
 public bool SaveToCameraRoll (string path) {
     return SharingBridge.SaveToCameraRoll(path);
 }
 public bool Share (string path) {
     return SharingBridge.Share(path);
 }