Well, I feel like a great big idiot.
I was telling my showVideoPlayerScreen function to return an Integer instead of a String, which is why I got the type mismatch.
I am going to post my working code here just in case anyone else would like to use this functionality but has a similar type of video array to mine. (the basic idea of the code came right from RokuJoel's example, but because I am pulling my video info from an API call, I had to do a lot of modification, plus I added a feature to make it loop back to the beginning when the last one plays)
Function getNewVidInfo(items, passIndex, pageTitle = invalid, parentPageTitle = invalid)
result = ""
while true
if(RegRead(PlayStartVariableName) <> invalid)
RegDelete(PlayStartVariableName)
'print "the regRead if statement was triggered"
end if
if (passIndex = items.count())
passIndex = 0
end if
index = passIndex
feedUrl = "/asset?id=" + tostr(items[index].ContentId) + "&fields=hls_url,closed_caption_urls,rating,duration,time_start,date,trick_mode_urls"
conn = InitFeedConnection(feedUrl)
response = conn.LoadFeed()
if response = invalid
return -1
end if
video = convertDvidsApiAssetResponse(response,items[index])
video.PlayStart = video.TimeStart
result = showVideoPlayerScreenAll(items, passIndex, video, pageTitle, invalid)
if result = "user cancelled" then
return result
end if
passIndex = passIndex +1
end while
End Function
Function showVideoPlayerScreenAll(items, passIndex, video As Object, pageTitle = invalid, parentPageTitle = invalid) As String
if type(video) <> "roAssociativeArray" then
print "invalid data passed to showVideoPlayerScreen"
return -1
end if
port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.setMessagePort(port)
if(video.ContentId <> invalid)
PlayStartVariableName = right(video.ContentId,6)+"pos" ' remove video- from contentid
screen.SetPositionNotificationPeriod(5)
end if
screenName = "asset_watch/" + right(video.ContentId,6)
screen.SetContent(video)
setBreadCrumbs(screen, pageTitle, parentPageTitle)
screen.Show()
while true
msg = wait(0, port)
if type(msg) = "roVideoScreenEvent" then
if msg.getmessage()= "Playback interrupted by user." then
return "user cancelled"
end if
if msg.isScreenClosed()
'print "Screen closed"
return ""
else if msg.isRequestFailed()
'print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
else if msg.isStatusMessage()
'print "Video status: "; msg.GetIndex(); " " msg.GetData()
else if msg.isButtonPressed()
'print "Button pressed: "; event.GetIndex(); " " event.GetData()
else if msg.isPlaybackPosition() then
currentPosition = msg.GetIndex()
' If we're less than 10 seconds from the end of the video go ahead and delete the position tracker
if(currentPosition + 10 > video.length and RegRead(PlayStartVariableName) <> invalid)
RegDelete(PlayStartVariableName)
else
'print "CurrentPosition";currentPosition
RegWrite(PlayStartVariableName, currentPosition.toStr())
end if
end if
end if
end while
End Function