コード例 #1
0
        /// <summary>
        /// Adds new media watch entry to history.
        /// </summary>
        /// <param name="entry">
        /// Entry to add. Id is ignored and gets overwritten if operation is successful.
        /// </param>
        /// <param name="thumbnailImage">
        /// Thumbnail image for entry. Format needs to be TextureFormat.RGB24.
        /// </param>
        /// <returns>
        /// MLResult.Result will be MLResult.Code.Ok if successful.
        ///
        /// MLResult.Result will be MLResult.Code.InvalidParam if failed due to invalid input parameter.
        ///
        /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error.
        ///
        /// MLResult.Result will be MLResult.Code.ScreensServiceNotAvailable if failed due to the unavailability of the screens service.
        /// </returns>
        public static MLResult Add(ref MLScreensWatchHistoryEntry entry, Texture2D thumbnailImage)
        {
            if (thumbnailImage == null)
            {
                return(MLResult.Create(MLResult.Code.InvalidParam, "Invalid null thumbnail parameter"));
            }

            return(Instance.InternalAdd(ref entry, thumbnailImage));
        }
コード例 #2
0
        private MLResult InternalGetEntry(long id, ref MLScreensWatchHistoryEntry entry)
        {
            if (!_watchHistory.ContainsKey(id))
            {
                return(MLResult.Create(MLResult.Code.InvalidParam, "Unknown entry Id"));
            }

            entry = _watchHistory[id];
            return(MLResult.Create(MLResult.Code.Ok));
        }
コード例 #3
0
        private void PopulateWatchHistory()
        {
            long screensArrayAddress = _watchHistoryList.Entries.ToInt64();

            for (var i = 0; i < _watchHistoryList.Count; ++i)
            {
                long entryAddress = screensArrayAddress +
                                    i * Marshal.SizeOf(typeof(MLScreensNativeBindings.MLScreensWatchHistoryEntryNative));
                var entryPtr    = new IntPtr(entryAddress);
                var nativeEntry =
                    (MLScreensNativeBindings.MLScreensWatchHistoryEntryNative)Marshal.PtrToStructure(entryPtr,
                                                                                                     typeof(MLScreensNativeBindings.MLScreensWatchHistoryEntryNative));
                MLScreensWatchHistoryEntry entry = nativeEntry.Data;
                _watchHistory.Add(entry.Id, entry);
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 /// <summary>
 /// Gets entry from media watch history.
 /// </summary>
 /// <param name="id">Id of existing media watch entry.</param>
 /// <param name="entry">Output entry if successful, unmodified otherwise.</param>
 /// <returns>
 /// MLResult.Result will be MLResult.Code.Ok if successful.
 ///
 /// MLResult.Result will be MLResult.Code.InvalidParam if failed due to invalid input parameter.
 /// </returns>
 public static MLResult GetEntry(long id, ref MLScreensWatchHistoryEntry entry)
 {
     return(Instance.InternalGetEntry(id, ref entry));
 }
コード例 #6
0
 /// <summary>
 /// Updates media watch entry.
 /// </summary>
 /// <param name="entry">Id of existing media watch entry.</param>
 /// <param name="thumbnailImage">
 /// Optional thumbnail image for entry. Format needs to be TextureFormat.RGB24. If left out, default thumbnail will be used.
 /// </param>
 /// <returns>
 /// MLResult.Result will be MLResult.Code.Ok if successful.
 ///
 /// MLResult.Result will be MLResult.Code.InvalidParam if failed due to invalid input parameter.
 ///
 /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error.
 ///
 /// MLResult.Result will be MLResult.Code.ScreensServiceNotAvailable if failed due to the unavailability of the screens service.
 /// </returns>
 public static MLResult UpdateWatchHistory(MLScreensWatchHistoryEntry entry, Texture2D thumbnailImage = null)
 {
     return(Instance.InternalUpdateWatchHistory(entry, thumbnailImage));
 }
コード例 #7
0
 /// <summary>
 /// Adds new media watch entry to history with default thumbnail.
 /// </summary>
 /// <param name="entry">
 /// Entry to add. Id is ignored and gets overwritten if operation is successful.
 /// </param>
 /// <returns>
 /// MLResult.Result will be MLResult.Code.Ok if successful.
 ///
 /// MLResult.Result will be MLResult.Code.InvalidParam if failed due to invalid input parameter.
 ///
 /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error.
 ///
 /// MLResult.Result will be MLResult.Code.ScreensServiceNotAvailable if failed due to the unavailability of the screens service.
 /// </returns>
 public static MLResult Add(ref MLScreensWatchHistoryEntry entry)
 {
     return(Instance.InternalAdd(ref entry, null));
 }