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.
19 namespace Tizen.Content.MediaContent
23 /// Represents the information related to the media stored.
25 /// <seealso cref="MediaInfoCommand"/>
26 /// <seealso cref="MediaInfoUpdateValues"/>
27 public class MediaInfo
29 internal MediaInfo(Interop.MediaInfoHandle handle)
31 Id = InteropHelper.GetString(handle, Interop.MediaInfo.GetMediaId);
33 Path = InteropHelper.GetString(handle, Interop.MediaInfo.GetFilePath);
34 DisplayName = InteropHelper.GetString(handle, Interop.MediaInfo.GetDisplayName);
36 MediaType = InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType);
38 MimeType = InteropHelper.GetString(handle, Interop.MediaInfo.GetMimeType);
40 FileSize = InteropHelper.GetValue<long>(handle, Interop.MediaInfo.GetSize);
42 DateAdded = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetAddedTime);
43 DateModified = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetModifiedTime);
44 Timeline = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetTimeline);
46 ThumbnailPath = InteropHelper.GetString(handle, Interop.MediaInfo.GetThumbnailPath, true);
47 Description = InteropHelper.GetString(handle, Interop.MediaInfo.GetDescription);
49 Longitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLongitude);
50 Latitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLatitude);
51 Altitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetAltitude);
53 Weather = InteropHelper.GetString(handle, Interop.MediaInfo.GetWeather);
54 Rating = InteropHelper.GetValue<int>(handle, Interop.MediaInfo.GetRating);
55 IsFavorite = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.GetFavorite);
56 Provider = InteropHelper.GetString(handle, Interop.MediaInfo.GetProvider);
57 Title = InteropHelper.GetString(handle, Interop.MediaInfo.GetTitle);
58 Category = InteropHelper.GetString(handle, Interop.MediaInfo.GetCategory);
59 LocationTag = InteropHelper.GetString(handle, Interop.MediaInfo.GetLocationTag);
60 AgeRating = InteropHelper.GetString(handle, Interop.MediaInfo.GetAgeRating);
61 StorageId = InteropHelper.GetString(handle, Interop.MediaInfo.GetStorageId);
62 IsDrm = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.IsDrm);
64 StorageType = InteropHelper.GetValue<StorageType>(handle, Interop.MediaInfo.GetStorageType);
68 /// Gets the ID of media.
70 /// <value>The unique ID of media.</value>
71 public string Id { get; }
74 /// Gets the path to media.
76 /// <value>The full path of the media file.</value>
77 public string Path { get; }
80 /// Gets the name of media.
82 /// <value>The base name of the media file.</value>
83 public string DisplayName { get; }
86 /// Gets the <see cref="MediaType"/> of media.
88 /// <value>The <see cref="MediaType"/> of media.</value>
89 public MediaType MediaType { get; }
92 /// Gets the mime type from media.
94 /// <value>The mime type of media.</value>
95 public string MimeType { get; }
98 /// Gets the file size of media in bytes.
100 /// <value>The file size of media in bytes.</value>
101 public long FileSize { get; }
104 /// Gets the date of addition of media.
106 /// <value>The date of addition of media.</value>
107 public DateTimeOffset DateAdded { get; }
110 /// Gets the date of modification of media.
112 /// <value>The date of modification of media.</value>
113 public DateTimeOffset DateModified { get; }
116 /// Gets the timeline of media.
119 /// The creation date if the file has the creation information (like recorded date or image creation date),
120 /// otherwise the modified date.
122 public DateTimeOffset Timeline { get; }
125 /// Gets the thumbnail of media.
127 /// <value>The thumbnail path of media.</value>
128 public string ThumbnailPath { get; }
131 /// Gets the description of media.
133 /// <value>The description from the metadata.</value>
134 public string Description { get; }
137 /// Gets the longitude of media.
139 /// <value>The longitude.</value>
140 public double Longitude { get; }
143 /// Gets the latitude of media.
145 /// <value>The latitude.</value>
146 public double Latitude { get; }
149 /// Gets the altitude of media.
151 /// <value>The altitude.</value>
152 public double Altitude { get; }
155 /// Gets the weather information of media.
157 /// <value>The weather information which a user sets.</value>
158 public string Weather { get; }
161 /// Gets the rating of media.
163 /// <value>The rating from the metadata.</value>
164 public int Rating { get; }
167 /// Gets the favorite status of media.
169 /// <value>true if media is set as favorite, otherwise false.</value>
170 public bool IsFavorite { get; }
173 /// Gets the provider of media.
175 /// <value>The provider which a user sets.</value>
176 public string Provider { get; }
179 /// Gets the title of media.
181 /// <value>The title of media.</value>
182 public string Title { get; }
185 /// Gets the category of media.
187 /// <value>The category which a user sets.</value>
188 public string Category { get; }
191 /// Gets the location tag of media.
193 /// <value>The location tag which a user sets.</value>
194 public string LocationTag { get; }
197 /// Gets the age rating of media.
199 /// <value>The age rating which a user sets.</value>
200 public string AgeRating { get; }
203 /// Gets the storage ID of the storage that the media is stored on.
205 /// <value>The storage ID of the storage that the media is stored on.</value>
206 public string StorageId { get; }
209 /// Gets the value indicating whether the media is DRM-protected.
211 /// <value>A bool value indicating whether the media is DRM-protected.</value>
212 public bool IsDrm { get; }
215 /// Gets the storage type of the storage that the media is stored on.
217 /// <value>The storage type of the storage that the media is stored on.</value>
218 public StorageType StorageType { get; }
221 /// Returns a string representation of the media information.
223 /// <returns>A string representation of the current media information.</returns>
224 public override string ToString() => $"Id={Id}, Path={Path}, MediaType={MediaType}";
226 internal static MediaInfo FromHandle(Interop.MediaInfoHandle handle)
228 if (handle == null || handle.IsInvalid)
233 var type = InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType);
237 case MediaType.Image:
238 return new ImageInfo(handle);
240 case MediaType.Music:
241 case MediaType.Sound:
242 return new AudioInfo(handle);
244 case MediaType.Video:
245 return new VideoInfo(handle);
248 return new MediaInfo(handle);
251 internal static MediaInfo FromHandle(IntPtr handle)
253 var safeHandle = new Interop.MediaInfoHandle(handle);
256 return FromHandle(safeHandle);
260 safeHandle.SetHandleAsInvalid();