Add a new method to get a recently played movie
authorKyuho Jo <kyuho.jo@samsung.com>
Fri, 14 Apr 2017 08:03:14 +0000 (17:03 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Fri, 14 Apr 2017 08:04:32 +0000 (17:04 +0900)
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
Change-Id: Ieddbe3cb1e7c18be825e390747cb96b8f0ee3076

TVMediaHub/TVMediaHub.Tizen/Models/VideoProvider.cs

index 153b668..b238b44 100755 (executable)
  */
 
 using System;
+using System.Collections.Generic;
+
+using Tizen;
+using Tizen.Content.MediaContent;
 
 namespace TVMediaHub.Tizen.Models
 {
@@ -27,5 +31,32 @@ namespace TVMediaHub.Tizen.Models
         {
             return "(MEDIA_TYPE=1)";
         }
+
+        public MediaInformation GetRecentlyPlayedVideo()
+        {
+            var contentFilter = new ContentFilter();
+            contentFilter.OrderKey = "MEDIA_LAST_PLAYED_TIME";
+            contentFilter.Order = ContentOrder.Desc;
+            contentFilter.Condition = GetConditionStringForSelection();
+
+            MediaInformation recentlyPlayedVideo = null;
+            IEnumerable<MediaInformation> mediaInformations = null;
+            try
+            {
+                mediaInformations = ContentManager.Database.SelectAll<MediaInformation>(contentFilter);
+            }
+            catch (Exception exception)
+            {
+                Log.Error("MediaHub", exception.Message);
+            }
+
+            foreach (var mediaInformation in mediaInformations)
+            {
+                recentlyPlayedVideo = mediaInformation;
+                break;
+            }
+
+            return recentlyPlayedVideo;
+        }
     }
 }
\ No newline at end of file