private MLResult InternalUpdateWatchHistory(MLScreensWatchHistoryEntry entry, Texture2D thumbnailImage) { if (!entry.IsValid) { return(MLResult.Create(MLResult.Code.InvalidParam, "Invalid entry parameter")); } if (!_watchHistory.ContainsKey(entry.Id)) { return(MLResult.Create(MLResult.Code.InvalidParam, "Unknown entry Id")); } if (thumbnailImage != null && thumbnailImage.format != TextureFormat.RGB24) { return(MLResult.Create(MLResult.Code.InvalidParam, "Invalid thumbnail parameter format")); } MLScreensNativeBindings.MLScreensWatchHistoryEntryNative nativeEntry = MLScreensNativeBindings.MLScreensWatchHistoryEntryNative.Create(); nativeEntry.Data = entry; MLImageNativeBindings.MLImageNative thumbnail = thumbnailImage == null ? _defaultGrayThumbnailImage : CreateThumbnailImage(thumbnailImage); MLResult.Code resultCode = MLScreensNativeBindings.MLScreensUpdateWatchHistoryEntry(ref nativeEntry, ref thumbnail); if (thumbnail.Image != IntPtr.Zero && thumbnail.Image != _defaultGrayThumbnailImage.Image) { Marshal.FreeHGlobal(thumbnail.Image); } Marshal.FreeHGlobal(nativeEntry.Title); Marshal.FreeHGlobal(nativeEntry.Subtitle); Marshal.FreeHGlobal(nativeEntry.CustomData); var result = MLResult.Create(resultCode); if (result.IsOk) { _watchHistory[entry.Id] = entry; } return(result); }