The problem with using the registry is you have a limited amount of space in Roku to hold data. So what I've done in the far far past was to keep the last 10 bookmarks in the roku ram and cycle them out so the oldest bookmark is erased and replaced with the newer bookmark. To get around that issue you can use a database on a server to query for a specific user and read the bookmarks they have, then search for a match to what the roku is currently looking at, or you could download the bookmarks with the content metadata list if your content selection is generated on demand by the server.
For the ancient roku registry code -
Going from lowest callback to highest (most active/least active routines) -
in the video playback routine when it is actually playing a video, you want to store the current position. Scenegraph sample apps store the bookmarks when the user stops playback themselves, but that doesn't trigger if the box crashes, is unplugged or the power goes out during playback, etc etc. so it might be better top store the position at set intervals.
In your springboard screen:
Initial display of buttons on the screen checks for an existing bookmark:
show=category
screen.ClearButtons()
sec=CreateObject("roRegistrySection",channelname)
found=0
For t=0 To 9
If sec.Exists(CHR(34)+CHR(48+t)+category.title)
found=1
Exit For
End If
Next
If found=1
screen.AddButton(1, "resume playing")
screen.AddButton(2, "play from beginning")
Else
screen.AddButton(1, "play")
End If
When the user selects something to play or resume:
If msg.GetIndex()=1 'Play/Resume Button on screen
Dim b[10]
Dim initialplace[10]
Dim v[10]
Dim bookmarks2[10]
'check registry If program exists
sec=CreateObject("roRegistrySection",channelname)
bookmarks=sec.GetKeyList()
i=0
For Each e In bookmarks 'count the bookmarks
'PrintAny(0, "List(" + itostr(i) + ")= ",e)
b[i]=MID(bookmarks[i],3) 'read episode titles
initialplace[i]=MID(bookmarks[i],2,1) 'read initial placement value
v[i]=RegRead(bookmarks[i],channelname) 'read playback position
bookmarks2[i]=bookmarks[i] 'backup bookmark names
i=i+1
Next
foundz=0
For tz=0 To i-1
If sec.Exists(CHR(34)+CHR(48+tz)+category.title)
foundz=1
category.PlayStart=RegRead(CHR(34)+CHR(48+tz)+category.title,channelname)
Exit For
End If
Next
If foundz=0
If i<10
RegWrite(CHR(34)+CHR(48+tz)+category.title, "0", channelname)
'Print"REGISTRY ENTRY WRITTEN"
'Print CHR(34)+CHR(48+tz)+category.title
'Print"END OF REGISTRY ENTRY WRITTEN"
Else
For tm=0 To i-1
'Print"Deleting ";bookmarks2[tm]
RegDelete(bookmarks2[tm],channelname)
Next
For tm=0 To i-2
b[tm]=b[tm+1]
initialplace[tm]=initialplace[tm+1]
v[tm]=v[tm+1]
'Print"WRITING NEW REGISTRY ";CHR(34)+CHR(48+tm)+b[tm]+" , "+v[tm]
RegWrite(CHR(34)+CHR(48+tm)+b[tm], v[tm], channelname)
Next
RegWrite(CHR(34)+CHR(57)+category.title, "0", channelname)
'Print"WRITING NEW REGISTRY final: ";CHR(34)+CHR(57)+category.title+" , 0"
tz=9
foundz=1
End If
End If
show=category
screen.ClearButtons()
sec=CreateObject("roRegistrySection",channelname)
found=0
For t=0 To 9
If sec.Exists(CHR(34)+CHR(48+t)+category.title)
found=1
Exit For
End If
Next
If found=1
screen.AddButton(1, "resume playing")
screen.AddButton(2, "play from beginning")
Else
screen.AddButton(1, "play")
End If
screen.SetContent(show)
screen.Show()
If foundz=1 showVideoScreen(category,tz)
If foundz=0 showVideoScreen(category,i)
End If
During the video playback --
Function showVideoScreen(episode As Object,t As Integer)
...
screen.SetPositionNotificationPeriod(30)
...
Else If msg.isPlaybackPosition()
nowpos=msg.GetIndex()
RegWrite(CHR(34)+CHR(48+t)+episode.title,nowpos.ToStr(),channelname)
You'll want to delete the bookmark when you get msg.isFullResult() during the video playback, meaning when a user has viewed the full video and update the onscreen button to replace "resume" with "play". The code for bookmarking is much easier using a server than the roku registry, as the registry can't be counted on to keep the key names in order, or you could probably try using a single key name for everything you need - there was some code posted on the forum to do that somewhere.