Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Content.MediaContent / Tizen.Content.MediaContent / MediaInformation.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18
19 using System;
20 using System.Collections.Generic;
21 using System.Collections.ObjectModel;
22 using System.Runtime.InteropServices;
23 using System.Threading;
24 using System.Threading.Tasks;
25
26 namespace Tizen.Content.MediaContent
27 {
28     /// <summary>
29     /// MediaContent class API gives the information related to the media stored in the device</summary>
30     /// <remarks>
31     /// The API's provide the functionlity to insert, clone, delete, get the number and content of files from DB.
32     /// You can get and set properties and parameters such as storage type, provider, and category of media info,
33     /// handling with thumbnail and updating media info to DB.</remarks>
34     public class MediaInformation
35     {
36         private readonly Interop.MediaInformation.SafeMediaInformationHandle _handle;
37
38         /// <summary>
39         /// Gets the count of media tags for the passed filter in the given mediaId from the media database.
40         /// </summary>
41         /// <since_tizen> 3 </since_tizen>
42         /// <returns>
43         /// int count</returns>
44         /// <param name="filter">The Filter for matching Tags</param>
45         public int GetTagCount(ContentFilter filter)
46         {
47             int count = 0;
48             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
49             MediaContentValidator.ThrowIfError(
50                 Interop.MediaInformation.GetTagCount(MediaId, handle, out count), "Failed to get count");
51
52             return count;
53         }
54
55         /// <summary>
56         /// Moves the media info to the given destination path in the media database.
57         /// </summary>
58         /// <since_tizen> 3 </since_tizen>
59         /// <returns>
60         /// void </returns>
61         /// <param name="destination">The Destination path</param>
62         public void Move(string destination)
63         {
64             MediaContentValidator.ThrowIfError(
65                 Interop.MediaInformation.MoveToDB(_handle, destination), "Failed to move");
66         }
67
68         /// <summary>
69         /// Refreshes the media metadata to the media database.
70         /// </summary>
71         /// <since_tizen> 3 </since_tizen>
72         /// <returns>
73         /// void </returns>
74         public void Refresh()
75         {
76             MediaContentValidator.ThrowIfError(
77                 Interop.MediaInformation.RefreshMetadataToDB(MediaId), "Failed to refresh");
78         }
79
80         /// <summary>
81         /// Creates a thumbnail image for the given media, asynchronously
82         /// If a thumbnail already exists for the given media, then the path of thumbnail will be returned.
83         /// </summary>
84         /// <since_tizen> 3 </since_tizen>
85         /// <returns>
86         /// Task for creation of Thumbnail </returns>
87         public Task<string> CreateThumbnailAsync()
88         {
89             var task = new TaskCompletionSource<string>();
90             Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) =>
91             {
92                 if (createResult != MediaContentError.None)
93                 {
94                     task.SetException(new InvalidOperationException("Failed to create thumbnail:" + createResult));
95                 }
96
97                 task.SetResult(path);
98             };
99             MediaContentValidator.ThrowIfError(
100                 Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail");
101
102             return task.Task;
103         }
104
105         /// <summary>
106         /// Creates a thumbnail image for the given media, asynchronously
107         /// which can be cancelled
108         /// If a thumbnail already exists for the given media, then the path of thumbnail will be returned.
109         /// </summary>
110         /// <since_tizen> 3 </since_tizen>
111         /// <param name="cancellationToken">Token to cancel the requested operation</param>
112         /// <returns>
113         /// Task for creation of Thumbnail
114         /// </returns>
115         public Task<string> CreateThumbnailAsync(CancellationToken cancellationToken)
116         {
117             var task = new TaskCompletionSource<string>();
118             cancellationToken.Register(() =>
119             {
120                 MediaContentValidator.ThrowIfError(
121                     Interop.MediaInformation.CancelThumbnail(_handle), "Failed to cancel");
122
123                 task.SetCanceled();
124             });
125
126             Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) =>
127             {
128                 if (createResult != MediaContentError.None)
129                 {
130                     task.SetException(new InvalidOperationException("Failed to create thumbnail:" + createResult));
131                 }
132
133                 task.SetResult(path);
134             };
135
136             MediaContentValidator.ThrowIfError(
137                 Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail");
138
139             return task.Task;
140         }
141
142         /// <summary>
143         /// Iterates through the media tag in the given media info from the media database.
144         /// </summary>
145         /// <since_tizen> 3 </since_tizen>
146         /// <returns>
147         /// Task to get all the Tags </returns>
148         /// <param name="filter"> The filter for the Tags</param>
149         public IEnumerable<Tag> GetTags(ContentFilter filter)
150         {
151             Collection<Tag> coll = new Collection<Tag>();
152
153             IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
154             Interop.MediaInformation.MediaTagCallback tagsCallback = (IntPtr tagHandle, IntPtr userData) =>
155             {
156                 IntPtr newHandle;
157                 MediaContentValidator.ThrowIfError(
158                     Interop.Tag.Clone(out newHandle, tagHandle), "Failed to clone");
159                 coll.Add(new Tag(newHandle));
160
161                 return true;
162             };
163             MediaContentValidator.ThrowIfError(
164                 Interop.MediaInformation.GetAllTags(MediaId, handle, tagsCallback, IntPtr.Zero), "Failed to get information");
165
166             return coll;
167         }
168
169         /// <summary>
170         ///  Gets the ID of the media.
171         /// </summary>
172         /// <since_tizen> 3 </since_tizen>
173         public virtual string MediaId
174         {
175             get
176             {
177                 IntPtr val = IntPtr.Zero;
178                 try
179                 {
180                     MediaContentValidator.ThrowIfError(
181                         Interop.MediaInformation.GetMediaId(_handle, out val), "Failed to get value");
182
183                     return Marshal.PtrToStringAnsi(val);
184                 }
185                 finally
186                 {
187                     Interop.Libc.Free(val);
188                 }
189             }
190         }
191
192         /// <summary>
193         ///  Gets the path to the media.
194         /// </summary>
195         /// <since_tizen> 3 </since_tizen>
196         public string FilePath
197         {
198             get
199             {
200                 IntPtr val = IntPtr.Zero;
201                 try
202                 {
203                     MediaContentValidator.ThrowIfError(
204                         Interop.MediaInformation.GetFilePath(_handle, out val), "Failed to get value");
205
206                     return Marshal.PtrToStringAnsi(val);
207                 }
208                 finally
209                 {
210                     Interop.Libc.Free(val);
211                 }
212             }
213         }
214
215         /// <summary>
216         ///  Name of the media.
217         /// </summary>
218         /// <since_tizen> 3 </since_tizen>
219         public string DisplayName
220         {
221             get
222             {
223                 IntPtr val = IntPtr.Zero;
224                 try
225                 {
226                     MediaContentValidator.ThrowIfError(
227                         Interop.MediaInformation.GetDisplayName(_handle, out val), "Failed to get value");
228
229                     return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
230                 }
231                 finally
232                 {
233                     Interop.Libc.Free(val);
234                 }
235             }
236
237             set
238             {
239                 MediaContentValidator.ThrowIfError(
240                     Interop.MediaInformation.SetDisplayName(_handle, value), "failed to set value");
241             }
242         }
243
244         /// <summary>
245         ///  Gets the content type of the media.
246         /// </summary>
247         /// <since_tizen> 3 </since_tizen>
248         public MediaContentType MediaType
249         {
250             get
251             {
252                 MediaContentType contentType = MediaContentType.Others;
253                 MediaContentValidator.ThrowIfError(
254                     Interop.MediaInformation.GetMediaType(_handle, out contentType), "Failed to get value");
255
256                 return contentType;
257             }
258         }
259
260         /// <summary>
261         ///  Gets the MIME type from the media.
262         /// </summary>
263         /// <since_tizen> 3 </since_tizen>
264         public string MimeType
265         {
266             get
267             {
268                 IntPtr val = IntPtr.Zero;
269                 try
270                 {
271                     MediaContentValidator.ThrowIfError(
272                         Interop.MediaInformation.GetMimeType(_handle, out val), "Failed to get value");
273
274                     return Marshal.PtrToStringAnsi(val);
275                 }
276                 finally
277                 {
278                     Interop.Libc.Free(val);
279                 }
280             }
281         }
282
283         /// <summary>
284         ///  Gets the media file size in bytes.
285         /// </summary>
286         /// <since_tizen> 3 </since_tizen>
287         public long Size
288         {
289             get
290             {
291                 long size;
292                 MediaContentValidator.ThrowIfError(
293                     Interop.MediaInformation.GetSize(_handle, out size), "Failed to get value");
294
295                 return size;
296             }
297         }
298
299         /// <summary>
300         ///  Addition time of the media.
301         /// </summary>
302         /// <since_tizen> 3 </since_tizen>
303         public DateTime AddedAt
304         {
305             get
306             {
307                 int time;
308                 MediaContentValidator.ThrowIfError(
309                     Interop.MediaInformation.GetAddedTime(_handle, out time), "Failed to get value");
310
311                 DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
312
313                 return utc.ToLocalTime();
314             }
315
316             set
317             {
318                 MediaContentValidator.ThrowIfError(
319                     Interop.MediaInformation.SetAddedTime(_handle, (int)value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds), "failed to set time");
320             }
321         }
322
323         /// <summary>
324         ///  Gets the date of modification of media.
325         /// </summary>
326         /// <since_tizen> 3 </since_tizen>
327         public DateTime ModifiedAt
328         {
329             get
330             {
331                 int time;
332                 MediaContentValidator.ThrowIfError(
333                     Interop.MediaInformation.GetModifiedTime(_handle, out time), "Failed to get value");
334
335                 DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
336
337                 return utc.ToLocalTime();
338             }
339         }
340
341         /// <summary>
342         ///  Gets the timeline of media.
343         /// </summary>
344         /// <since_tizen> 3 </since_tizen>
345         public DateTime TimeLine
346         {
347             get
348             {
349                 int time;
350                 MediaContentValidator.ThrowIfError(
351                     Interop.MediaInformation.GetTimeline(_handle, out time), "Failed to get value");
352
353                 DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
354
355                 return utc.ToLocalTime();
356             }
357         }
358
359         /// <summary>
360         ///  Gets the thumbnail of media.
361         /// </summary>
362         /// <since_tizen> 3 </since_tizen>
363         public string ThumbnailPath
364         {
365             get
366             {
367                 IntPtr val = IntPtr.Zero;
368                 try
369                 {
370                     MediaContentValidator.ThrowIfError(
371                         Interop.MediaInformation.GetThumbnailPath(_handle, out val), "Failed to get value");
372
373                     return Marshal.PtrToStringAnsi(val);
374                 }
375                 finally
376                 {
377                     Interop.Libc.Free(val);
378                 }
379             }
380         }
381
382         /// <summary>
383         ///  Description of media.
384         ///  If the media info has no description, the property returns empty string.
385         /// </summary>
386         /// <since_tizen> 3 </since_tizen>
387         public string Description
388         {
389             get
390             {
391                 IntPtr val = IntPtr.Zero;
392                 try
393                 {
394                     MediaContentValidator.ThrowIfError(
395                         Interop.MediaInformation.GetDescription(_handle, out val), "Failed to get value");
396
397                     return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
398                 }
399                 finally
400                 {
401                     Interop.Libc.Free(val);
402                 }
403             }
404
405             set
406             {
407                 MediaContentValidator.ThrowIfError(
408                     Interop.MediaInformation.SetDescription(_handle, value), "failed to set value");
409             }
410         }
411
412         /// <summary>
413         /// Longitude of media.
414         /// Default Value is 0.0.
415         /// </summary>
416         /// <since_tizen> 3 </since_tizen>
417         public double Longitude
418         {
419             get
420             {
421                 double longitude = 0.0;
422                 MediaContentValidator.ThrowIfError(
423                     Interop.MediaInformation.GetLongitude(_handle, out longitude), "Failed to get value");
424
425                 return longitude;
426             }
427
428             set
429             {
430                 MediaContentValidator.ThrowIfError(
431                     Interop.MediaInformation.SetLongitude(_handle, value), "failed to set value");
432             }
433         }
434
435         /// <summary>
436         /// Latitude of media.
437         /// Default Value is 0.0.
438         /// </summary>
439         /// <since_tizen> 3 </since_tizen>
440         public double Latitude
441         {
442             get
443             {
444                 double latitude = 0.0;
445                 MediaContentValidator.ThrowIfError(
446                     Interop.MediaInformation.GetLatitude(_handle, out latitude), "Failed to get value");
447
448                 return latitude;
449             }
450
451             set
452             {
453                 MediaContentValidator.ThrowIfError(
454                     Interop.MediaInformation.SetLatitude(_handle, value), "failed to set value");
455             }
456         }
457
458         /// <summary>
459         /// Altitude of media.
460         /// Default Value is 0.0.
461         /// </summary>
462         /// <since_tizen> 3 </since_tizen>
463         public double Altitude
464         {
465             get
466             {
467                 double altitude = 0.0;
468                 MediaContentValidator.ThrowIfError(
469                     Interop.MediaInformation.GetAltitude(_handle, out altitude), "Failed to get value");
470
471                 return altitude;
472             }
473
474             set
475             {
476                 MediaContentValidator.ThrowIfError(
477                     Interop.MediaInformation.SetAltitude(_handle, value), "failed to set value");
478             }
479         }
480
481         /// <summary>
482         /// Weather information of media.
483         /// </summary>
484         /// <since_tizen> 3 </since_tizen>
485         public string Weather
486         {
487             get
488             {
489                 IntPtr val = IntPtr.Zero;
490                 try
491                 {
492                     MediaContentValidator.ThrowIfError(
493                         Interop.MediaInformation.GetWeather(_handle, out val), "Failed to get value");
494
495                     return Marshal.PtrToStringAnsi(val);
496                 }
497                 finally
498                 {
499                     Interop.Libc.Free(val);
500                 }
501             }
502
503             set
504             {
505                 MediaContentValidator.ThrowIfError(
506                     Interop.MediaInformation.SetWeather(_handle, value), "failed to set value");
507             }
508         }
509
510         /// <summary>
511         /// Rating of media.
512         /// </summary>
513         /// <since_tizen> 3 </since_tizen>
514         public int Rating
515         {
516             get
517             {
518                 int rating = 0;
519                 MediaContentValidator.ThrowIfError(
520                     Interop.MediaInformation.GetRating(_handle, out rating), "Failed to get value");
521                 return rating;
522             }
523
524             set
525             {
526                 MediaContentValidator.ThrowIfError(
527                     Interop.MediaInformation.SetRating(_handle, value), "failed to set value");
528             }
529         }
530
531         /// <summary>
532         /// Favorite status of media.
533         /// true if media info is set as favorite, otherwise false if media info is not set as favorite.
534         /// </summary>
535         /// <since_tizen> 3 </since_tizen>
536         public bool IsFavourite
537         {
538             get
539             {
540                 bool isFavourtite = false;
541                 MediaContentValidator.ThrowIfError(
542                     Interop.MediaInformation.GetFavorite(_handle, out isFavourtite), "Failed to get value");
543
544                 return isFavourtite;
545             }
546
547             set
548             {
549                 MediaContentValidator.ThrowIfError(
550                     Interop.MediaInformation.SetFavorite(_handle, value), "failed to set value");
551             }
552         }
553
554         /// <summary>
555         /// Author of media.
556         /// </summary>
557         /// <since_tizen> 3 </since_tizen>
558         public string Author
559         {
560             get
561             {
562                 IntPtr val = IntPtr.Zero;
563                 try
564                 {
565                     MediaContentValidator.ThrowIfError(
566                         Interop.MediaInformation.GetAuthor(_handle, out val), "Failed to get value");
567
568                     return Marshal.PtrToStringAnsi(val);
569                 }
570                 finally
571                 {
572                     Interop.Libc.Free(val);
573                 }
574             }
575
576             set
577             {
578                 MediaContentValidator.ThrowIfError(
579                     Interop.MediaInformation.SetAuthor(_handle, value), "failed to set value");
580             }
581         }
582
583         /// <summary>
584         /// Provider of media.
585         /// </summary>
586         /// <since_tizen> 3 </since_tizen>
587         public string Provider
588         {
589             get
590             {
591                 IntPtr val = IntPtr.Zero;
592                 try
593                 {
594                     MediaContentValidator.ThrowIfError(
595                         Interop.MediaInformation.GetProvider(_handle, out val), "Failed to get value");
596
597                     return Marshal.PtrToStringAnsi(val);
598                 }
599                 finally
600                 {
601                     Interop.Libc.Free(val);
602                 }
603             }
604
605             set
606             {
607                 MediaContentValidator.ThrowIfError(
608                     Interop.MediaInformation.SetProvider(_handle, value), "failed to set value");
609             }
610         }
611
612         /// <summary>
613         /// Content name of media.
614         /// </summary>
615         /// <since_tizen> 3 </since_tizen>
616         public string ContentName
617         {
618             get
619             {
620                 IntPtr val = IntPtr.Zero;
621                 try
622                 {
623                     MediaContentValidator.ThrowIfError(
624                         Interop.MediaInformation.GetContentName(_handle, out val), "Failed to get value");
625
626                     return Marshal.PtrToStringAnsi(val);
627                 }
628                 finally
629                 {
630                     Interop.Libc.Free(val);
631                 }
632             }
633
634             set
635             {
636                 MediaContentValidator.ThrowIfError(
637                     Interop.MediaInformation.SetContentName(_handle, value), "failed to set value");
638             }
639         }
640
641         /// <summary>
642         /// Gets the title of media.
643         /// If the media content has no title, the property returns empty string.
644         /// </summary>
645         /// <since_tizen> 3 </since_tizen>
646         public string Title
647         {
648             get
649             {
650                 IntPtr val = IntPtr.Zero;
651                 try
652                 {
653                     MediaContentValidator.ThrowIfError(
654                         Interop.MediaInformation.GetTitle(_handle, out val), "Failed to get value");
655
656                     return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
657                 }
658                 finally
659                 {
660                     Interop.Libc.Free(val);
661                 }
662             }
663         }
664
665         /// <summary>
666         /// Category of media.
667         /// </summary>
668         /// <since_tizen> 3 </since_tizen>
669         public string Category
670         {
671             get
672             {
673                 IntPtr val = IntPtr.Zero;
674                 try
675                 {
676                     MediaContentValidator.ThrowIfError(
677                         Interop.MediaInformation.GetCategory(_handle, out val), "Failed to get value");
678
679                     return Marshal.PtrToStringAnsi(val);
680                 }
681                 finally
682                 {
683                     Interop.Libc.Free(val);
684                 }
685             }
686
687             set
688             {
689                 MediaContentValidator.ThrowIfError(
690                     Interop.MediaInformation.SetCategory(_handle, value), "failed to set value");
691             }
692         }
693
694         /// <summary>
695         /// location tag of media.
696         /// </summary>
697         /// <since_tizen> 3 </since_tizen>
698         public string LocationTag
699         {
700             get
701             {
702                 IntPtr val = IntPtr.Zero;
703                 try
704                 {
705                     MediaContentValidator.ThrowIfError(
706                         Interop.MediaInformation.GetLocationTag(_handle, out val), "Failed to get value");
707
708                     return Marshal.PtrToStringAnsi(val);
709                 }
710                 finally
711                 {
712                     Interop.Libc.Free(val);
713                 }
714             }
715
716             set
717             {
718                 MediaContentValidator.ThrowIfError(
719                     Interop.MediaInformation.SetLocationTag(_handle, value), "failed to set value");
720             }
721         }
722
723         /// <summary>
724         /// Age Rating of media.
725         /// </summary>
726         /// <since_tizen> 3 </since_tizen>
727         public string AgeRating
728         {
729             get
730             {
731                 IntPtr val = IntPtr.Zero;
732                 try
733                 {
734                     MediaContentValidator.ThrowIfError(
735                         Interop.MediaInformation.GetAgeRating(_handle, out val), "Failed to get value");
736
737                     return Marshal.PtrToStringAnsi(val);
738                 }
739                 finally
740                 {
741                     Interop.Libc.Free(val);
742                 }
743             }
744
745             set
746             {
747                 MediaContentValidator.ThrowIfError(
748                     Interop.MediaInformation.SetAgeRating(_handle, value), "Failed to set value");
749             }
750         }
751
752         /// <summary>
753         /// Keyword of media.
754         /// </summary>
755         /// <since_tizen> 3 </since_tizen>
756         public string Keyword
757         {
758             get
759             {
760                 IntPtr val = IntPtr.Zero;
761                 try
762                 {
763                     MediaContentValidator.ThrowIfError(
764                         Interop.MediaInformation.GetKeyword(_handle, out val), "Failed to get value");
765
766                     return Marshal.PtrToStringAnsi(val);
767                 }
768                 finally
769                 {
770                     Interop.Libc.Free(val);
771                 }
772             }
773
774             set
775             {
776                 MediaContentValidator.ThrowIfError(
777                     Interop.MediaInformation.SetKeyword(_handle, value), "failed to set value");
778             }
779         }
780
781         /// <summary>
782         /// Gets the storage id of media.
783         /// </summary>
784         /// <since_tizen> 3 </since_tizen>
785         public string StorageId
786         {
787             get
788             {
789                 IntPtr val = IntPtr.Zero;
790                 try
791                 {
792                     MediaContentValidator.ThrowIfError(
793                         Interop.MediaInformation.GetStorageId(_handle, out val), "Failed to get value");
794
795                     return Marshal.PtrToStringAnsi(val);
796                 }
797                 finally
798                 {
799                     Interop.Libc.Free(val);
800                 }
801             }
802         }
803
804         /// <summary>
805         /// Checks whether the media is protected via DRM.
806         /// </summary>
807         /// <since_tizen> 3 </since_tizen>
808         public bool IsDrm
809         {
810             get
811             {
812                 bool isDRM = false;
813                 MediaContentValidator.ThrowIfError(
814                     Interop.MediaInformation.IsDrm(_handle, out isDRM), "Failed to get value");
815
816                 return isDRM;
817             }
818         }
819
820         /// <summary>
821         /// Gets the storage type of media.
822         /// </summary>
823         /// <since_tizen> 3 </since_tizen>
824         public ContentStorageType StorageType
825         {
826             get
827             {
828                 ContentStorageType storageType = ContentStorageType.Internal;
829                 MediaContentValidator.ThrowIfError(
830                     Interop.MediaInformation.GetStorageType(_handle, out storageType), "Failed to get value");
831
832                 return storageType;
833             }
834         }
835
836         /// <summary>
837         /// Number which represents how many times given content has been played.
838         /// While Setting the played count, it will only be incremented by 1, the value provided will be ignored.
839         /// </summary>
840         /// <since_tizen> 3 </since_tizen>
841         public int PlayedCount
842         {
843             get
844             {
845                 int playedCount = 0;
846                 MediaContentValidator.ThrowIfError(
847                     Interop.MediaInformation.GetPlayedCount(_handle, out playedCount), "Failed to get value");
848
849                 return playedCount;
850             }
851
852             set
853             {
854                 MediaContentValidator.ThrowIfError(
855                     Interop.MediaInformation.IncreasePlayedCount(_handle), "failed to set value");
856             }
857         }
858
859         /// <summary>
860         ///  Content's latest played(opened) time of the media file.
861         ///  for set the current time is automatically taken from the system, the value provided will be ignored.
862         /// </summary>
863         /// <since_tizen> 3 </since_tizen>
864         public DateTime PlayedAt
865         {
866             get
867             {
868                 int time;
869                 MediaContentValidator.ThrowIfError(
870                     Interop.MediaInformation.GetPlayedAt(_handle, out time), "Failed to get value");
871
872                 DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
873
874                 return utc.ToLocalTime();
875             }
876
877             set
878             {
879                 MediaContentValidator.ThrowIfError(
880                     Interop.MediaInformation.SetPlayedAt(_handle), "failed to set value");
881             }
882         }
883
884         internal IntPtr MediaHandle
885         {
886             get
887             {
888                 return _handle.DangerousGetHandle();
889             }
890         }
891
892         internal MediaInformation(Interop.MediaInformation.SafeMediaInformationHandle handle)
893         {
894             _handle = handle;
895         }
896     }
897 }