2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 using System.Runtime.InteropServices;
22 namespace Tizen.Content.MediaContent
25 /// A MediaBookmark allows you to mark interesting moment in a media(video and audio) to enable fast searching.
26 /// The MediaBookmark Information API provides functions to get information about bookmarks associated with video and audio items.
28 public class MediaBookmark : IDisposable
30 private IntPtr _bookmarkHandle = IntPtr.Zero;
31 private bool _disposedValue = false;
37 if (_bookmarkHandle == IntPtr.Zero)
39 throw new ObjectDisposedException(nameof(MediaBookmark));
42 return _bookmarkHandle;
45 internal MediaBookmark(IntPtr handle)
47 _bookmarkHandle = handle;
55 /// The media bookmark ID
57 /// <since_tizen> 3 </since_tizen>
63 MediaContentValidator.ThrowIfError(
64 Interop.MediaBookmark.GetBookmarkId(Handle, out id), "Failed to get bookmark id");
71 /// The thumbnail path of media bookmark
73 /// <since_tizen> 3 </since_tizen>
74 public string ThumbnailPath
78 IntPtr val = IntPtr.Zero;
81 MediaContentValidator.ThrowIfError(
82 Interop.MediaBookmark.GetThumbnailPath(Handle, out val), "Failed to get bookmark thumbnail");
84 return Marshal.PtrToStringAnsi(val);
88 Interop.Libc.Free(val);
94 /// The bookmark time offset (in milliseconds)
96 /// <since_tizen> 3 </since_tizen>
102 MediaContentValidator.ThrowIfError(
103 Interop.MediaBookmark.GetMarkedTime(Handle, out offset), "Failed to get bookmarked time");
109 public void Dispose()
112 GC.SuppressFinalize(this);
115 protected virtual void Dispose(bool disposing)
119 if (_bookmarkHandle != IntPtr.Zero)
121 Interop.MediaBookmark.Destroy(_bookmarkHandle);
122 _bookmarkHandle = IntPtr.Zero;
125 _disposedValue = true;