commit 50532094fefcb055969c61b1d7c0200051d800a2
parent 69027345e3856a91686be7ee5a827c8100d3e635
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Sat, 30 Dec 2023 12:06:08 -0800
Add save/recall of last played video
Diffstat:
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/HMS/components/KeystoreTask.brs b/HMS/components/KeystoreTask.brs
@@ -31,5 +31,3 @@ sub ExecuteCommand()
 
     m.top.done = true
 end sub
-
-
diff --git a/HMS/components/MainScene.brs b/HMS/components/MainScene.brs
@@ -177,6 +177,9 @@ sub OnMetadataLoaded()
         cn.appendChild(n)
     end for
     m.posterGrid.content = cn
+
+    ' Try to get the last selected poster for this category
+    GetKeystoreValue(m.metadataTask.category, "JumpToPoster")
 end sub
 
 ' OnPosterSelected it called when OK is hit on the selected poster
@@ -185,6 +188,9 @@ sub OnPosterSelected()
     print "MainScene->OnPosterSelected()"
     print m.posterGrid.itemSelected
     StartVideoPlayer(m.posterGrid.itemSelected)
+
+    ' Store the new selection for this category
+    SetKeystoreValue(m.metadataTask.category, m.posterGrid.itemSelected.ToStr(), "ResetKeystoreTask")
 end sub
 
 ' OnPosterFocused updates the information at the top of the screen with the
@@ -197,6 +203,24 @@ sub OnPosterFocused()
 end sub
 
 
+' JumpToPoster moves the selection to the last played video if there is one
+sub JumpToPoster()
+    ResetKeystoreTask()
+
+    ' Was there a result?
+    if m.keystoreTask.value <> ""
+        item =  m.keystoreTask.value.ToInt()
+        if item < m.metadata.Count()
+            ' If the animation will be short, animate, otherwise jump
+            if item < 42
+                m.posterGrid.animateToItem = item
+            else
+                m.posterGrid.jumpToItem = item
+            end if
+        end if
+    end if
+end sub
+
 '***********************
 ' Video player functions
 '***********************