Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
uarlive
Visitor

Issue with hls and resume buttons

Hello. I am experiencing an issue where the "resume" and "start from the beginning" buttons appear when a live feed has been exited. The buttons behave as expected on mp4 content but I am trying to remove them from live feeds which are supplied through a xml file. Can someone point me in the right direction? Thanks.

appShowFeed.brs

'fetch all values from the xml for the current show
item.hdImg = validstr(curShow@hdImg)
item.sdImg = validstr(curShow@sdImg)
item.ContentId = validstr(curShow.contentId.GetText())
item.Title = validstr(curShow.title.GetText())
item.Description = validstr(curShow.description.GetText())
item.ContentType = validstr(curShow.contentType.GetText())
item.ContentQuality = validstr(curShow.contentQuality.GetText())
item.Synopsis = validstr(curShow.synopsis.GetText())
item.Genre = validstr(curShow.genres.GetText())
item.Runtime = validstr(curShow.runtime.GetText())
item.HDBifUrl = validstr(curShow.hdBifUrl.GetText())
item.SDBifUrl = validstr(curShow.sdBifUrl.GetText())
item.StreamFormat = validstr(curShow.streamFormat.GetText())
item.SwitchingStrategy = validstr(curshow.switchingStrategy.gettext())
if item.StreamFormat = "" then 'set default streamFormat to mp4 if doesn't exist in xml
item.StreamFormat = "mp4"
elseif item.StreamFormat = "hls" then
item.StreamFormat = "hls"
item.SwitchingStrategy="full-adaptation"
endif


appVideoScreen.brs



Function showVideoScreen(showList As Object, showIndex as Integer)
if validateParam(showList, "roArray", "refreshShowDetail") = false return -1
episode = showList[showIndex]
' if (not BillReminder()) then return invalid
' Track(episode["contentId"])
port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(port)

screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()

'Uncomment his line to dump the contents of the episode to be played
PrintAA(episode)

while true
msg = wait(0, port)

if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
elseif msg.isfullresult()
RegDelete(episode.ContentId)
elseif msg.isRequestFailed() then
showVideoFailureMessage()
'print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
else
print "Unexpected event type: "; msg.GetType()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while

End Function


appDetail.brs

Function refreshShowDetail(screen As Object, showList As Object, showIndex as Integer) As Integer

if validateParam(screen, "roSpringboardScreen", "refreshShowDetail") = false return -1
if validateParam(showList, "roArray", "refreshShowDetail") = false return -1

show = showList[showIndex]
'Uncomment this statement to dump the details for each show
PrintAA(show)

if show.contentformat <> "audio"
screen.ClearButtons()
if regread(show.contentid) <> invalid and regread(show.contentid).toint() >=30 then
screen.AddButton(1, "Resume Playing")
screen.AddButton(2, "Play from Beginning")
screen.SetStaticRatingEnabled(false)
else
screen.addbutton(2,"Play")
screen.SetStaticRatingEnabled(false)
end if
screen.SetContent(show)
screen.Show()
else
screen.ClearButtons()
if(m.playing = 1) then
if(m.paused = 0) then
screen.AddButton(1, "Pause")
else
screen.AddButton(1, "Resume")
end if
screen.AddButton(3, "Stop")
else
screen.AddButton(2, "Play")
end if
screen.SetContent(show)
screen.SetStaticRatingEnabled(false)
screen.Show()
endif
End Function
0 Kudos
4 REPLIES 4
bandal
Visitor

Re: Issue with hls and resume buttons

Try adding refreshShowDetail(screen,showList,showIndex) under the While True line in appDetailScreen.brs under the function showDetailScreen
It may work.
0 Kudos
uarlive
Visitor

Re: Issue with hls and resume buttons

Thanks. but that didnt work.
0 Kudos
RokuMarkn
Visitor

Re: Issue with hls and resume buttons

As far as I can see, you're not treating HLS differently anywhere. You're doing the RegWrite of the video position for both live and VOD, which causes your refreshShowDetail function to create the resume button. If you don't want that behavior, check whether your content is live (or is HLS or whatever condition you want to use) before writing the position to the registry in your event loop.

--Mark
0 Kudos
uarlive
Visitor

Re: Issue with hls and resume buttons

thanks. that helped. wound up using this.


Function refreshShowDetail(screen As Object, showList As Object, showIndex as Integer) As Integer

if validateParam(screen, "roSpringboardScreen", "refreshShowDetail") = false return -1
if validateParam(showList, "roArray", "refreshShowDetail") = false return -1

show = showList[showIndex]
'Uncomment this statement to dump the details for each show
PrintAA(show)

if show.contentformat <> "audio" and show.streamformat <> "hls"
screen.ClearButtons()
if regread(show.contentid) <> invalid and regread(show.contentid).toint() >=30 then
screen.AddButton(1, "Resume Playing")
screen.AddButton(2, "Play from Beginning")
screen.SetStaticRatingEnabled(false)
else
screen.addbutton(2,"Play")
screen.SetStaticRatingEnabled(false)
end if
screen.SetContent(show)
screen.Show()
else
screen.ClearButtons()
if(m.playing = 1) then
if(m.paused = 0) then
screen.AddButton(1, "Pause")
else
screen.AddButton(1, "Resume")
end if
screen.AddButton(3, "Stop")
else
screen.AddButton(2, "Play")
end if
screen.SetContent(show)
screen.SetStaticRatingEnabled(false)
screen.Show()
endif
End Function
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.