Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
uarlive
Level 7

issue with resume and vast

I am having trouble implementing the resume feature from the springboard. I can read the registry and print the episode.id and saved position. When ShowVideoScreen(episode).Playstart = 30 is called from the console the ShowVideoScreen function ignores the index value and plays the video from the beginning. Any help is appreciated.

Springboard Function
Function ShowSpringboardScreen(episode)
screen = CreateObject("roSpringboardScreen")
screen.SetMessagePort(CreateObject("roMessagePort"))
'screen.SetBreadcrumbText(leftBread, rightBread)
screen.SetDescriptionStyle("movie")
print RegRead(episode.id)
screen.ClearButtons()

if RegRead(episode.id) <> invalid and RegRead(episode.id).toint() >=10 then
screen.AddButton(1, "Watch Now")
screen.AddButton(2, "Resume")
else
screen.addbutton(1, "Watch Now")
end if

screen.SetContent(episode)
screen.SetStaticRatingEnabled(false)
screen.AllowUpdates(true)
screen.Show()

while true
msg = wait(0, screen.GetMessagePort())

if type(msg) = "roSpringboardScreenEvent"
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
if msg.GetIndex() = 1
PlayVideo(episode)
endif
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
else
print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()
endif
end while

return true
End Function


ShowVideoScreen Function in the modified VAST brs.
sub ShowVideoScreen(episode as object) as integer
screen = CreateObject("roVideoScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort( port )

metaData = {
ContentType: episode.contentType,
VideoId: episode.id,
Title: episode.title,
Description: episode.description,
length: episode.length,
Stream: {
Url: episode.url
}
StreamFormat: episode.streamformat
}

screen.SetPositionNotificationPeriod(1)
screen.SetContent(metaData)
screen.show()

while true
msg = wait(0, port)
if type(msg) = "roVideoScreenEvent" then
print "showVideoScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isfullresult()
RegDelete(episode.id)
else if msg.isPartialResult()
'RegWrite(episode.id, nowpos.toStr())
else if msg.isRequestFailed() then
showVideoFailureMessage()
'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: "; msg.GetIndex(); " " msg.GetData()
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.id, nowpos.toStr())
else if msg.isPaused() then
else if msg.isResumed() then
end if
else
print "Unexpected message class: "; type(msg)
end if
end while

end sub
0 Kudos
6 REPLIES 6\
destruk
Level 10

Re: issue with resume and vast

You'll either need to set the playstart value for the episode before sending it to the showvideoscreen routine, pass the value for playstart into the showvideoscreen routine to be set before playback, or re-read the value from the registry to re-obtain the resume position and set playstart for the episode before initiating playback. Any one of those should resolve the issue.
0 Kudos
uarlive
Level 7

Re: issue with resume and vast

Thanks Destruk. I passed the Playstart value to the ShowVideoScreen function and it still ignores the playstart value. To note I am using the modified appvideoscreen from the VAST 2.0 SDK.

Springboard loop
    while true
msg = wait(0, screen.GetMessagePort())

if type(msg) = "roSpringboardScreenEvent"
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
if msg.GetIndex() = 1
PlayVideo(episode)
endif
if msg.GetIndex() = 2
PlayStart = RegRead(episode.id)
if PlayStart <> invalid then
episode.PlayStart = PlayStart.ToInt()
ShowVideoScreen(episode)
endif
endif
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
else
print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()
endif
end while



From the Debugger console

Local Variables:
episode &h4010 bsc:roAssociativeArray, refcnt=2
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=3
screen &h0010 bsc:roSpringboardScreen, refcnt=1
msg &h0000 <uninitialized> val:Uninitialized
playstart &h0000 <uninitialized> val:Uninitialized
BrightScript Debugger> PlayStart = RegRead(episode.id)
BrightScript Debugger> print Playstart
256
BrightScript Debugger> episode.PlayStart = PlayStart.ToInt()
BrightScript Debugger> print episode.PlayStart
256
BrightScript Debugger> print episode

sdposterurl: http://.png
description: invalid
rating: invalid
director: invalid
streamformat: mp4
length: 4541
url: http://.mp4
hdposterurl: http://.png
playstart: 256
title: TheLimpingMan
id: 6cfbee868849d50afdfce0611f2e2b87
contenttype: episode
0 Kudos
destruk
Level 10

Re: issue with resume and vast

Your playvideo routine isn't actually using the episode to play back the content - it is picking and choosing which variable sets to use and playing 'metadata'

metaData = {
ContentType: episode.contentType,
VideoId: episode.id,
Title: episode.title,
Description: episode.description,
length: episode.length,
Stream: {
Url: episode.url
}
StreamFormat: episode.streamformat
}

So you'd need to add playstart to that in this case.
0 Kudos
uarlive
Level 7

Re: issue with resume and vast

destruk,

It seems to be working. Thanks again. To refresh the springboard screen to show the updated status of resume should I just call ShowSpringboardScreen(episode) again when the screen is closed?

Vast_VideoScreen.brs


while true
msg = wait(0, port)
if type(msg) = "roVideoScreenEvent" then
print "showVideoScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
ShowSpringboardScreen(episode)
exit while
0 Kudos
destruk
Level 10

Re: issue with resume and vast

Yeah, show will update it with current data - so if you update your buttons and then call show, it'll be fine.
What I'd do is add it to the Springboardscreen routine

if msg.GetIndex() = 1
PlayVideo(episode)
endif
if msg.GetIndex() = 2
PlayStart = RegRead(episode.id)
if PlayStart <> invalid then
episode.PlayStart = PlayStart.ToInt()
ShowVideoScreen(episode)
endif
endif

After ShowVideoscreen(episode) and after PlayVideo(episode) I'd have it update the buttons there and refresh the screen before the end if.
0 Kudos
uarlive
Level 7

Re: issue with resume and vast

Its all working. Thanks again.
0 Kudos