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: 
jnicholas
Visitor

Dynamically updating poster images

I am working on a Roku Channel that has some live content that is only on for a limited part of the day. I'd like to have a poster image that looks one way when the live stream is not available and is not selectable but once the live stream is available I change the image and the user can select it. To do this I would need to have some way to regularly poll to detect if the stream is available or not and then change the image once it is. Any advice on how to accomplish this? I don't see anything that would let me have a timer or polling loop. I'm also not sure if I can update an existing graphic.

Any pointers on other interface approaches that would be better would be appreciated also.
0 Kudos
9 REPLIES 9
destruk
Streaming Star

Re: Dynamically updating poster images

If you attach a timestamp to the end of the thumbnail file, then it'll always pull down a new image instead of caching it.
If the stream becomes available at the same time every day, and unavailable at the same time every day, then you can get the system time from the roku, and have the channel do the conversion to the time zone you're using (GMT for ease of use), and swap the image out that way without needing to poll the server - assuming that to have it recheck the user would exit the screen and reenter it again.
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: Dynamically updating poster images

"jnicholas" wrote:
Any advice on how to accomplish this? I don't see anything that would let me have a timer or polling loop.


Check out roTimespan in the Component Reference. You can also provide a non-zero argument to the Wait() call inside an event loop. The register example in the SDK uses the latter approach.

"jnicholas" wrote:
I'm also not sure if I can update an existing graphic.


Just change the item's sdPosterURL and hdPosterURL and call the screen's SetContentList() and Show() methods.
0 Kudos
destruk
Streaming Star

Re: Dynamically updating poster images

Or you could manually inject a poster item before parsing your xml file to add a "refresh list" so the user can select that to get current data....
0 Kudos
jnicholas
Visitor

Re: Dynamically updating poster images

"destruk" wrote:
Or you could manually inject a poster item before parsing your xml file to add a "refresh list" so the user can select that to get current data....


What I'm trying to do is change the UI while a user is on a screen. While it would be easy to change the path to the image and the stream on the server side to reflect the availability of the show it makes for an awkward experience. Picture that you have loaded a channel and it says that there will be a live show at 7:00. You would find it annoying to have to go back to the previous screen and forward to the live screen again to get the updated image and feed from the new xml. It would be much friendlier to have the UI change to say "Now Showing" or "Live" or similar and then you just click. Even better would be for it to just start playing but I'm pretty sure there's no way to trigger that automatically.
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: Dynamically updating poster images

"jnicholas" wrote:
Even better would be for it to just start playing but I'm pretty sure there's no way to trigger that automatically.


If you can detect within your polling loop that a stream has become live, there's no reason you can't start playback automatically.
0 Kudos
jbrave
Channel Surfer

Re: Dynamically updating poster images

Actually, a posterscreen updates its content as soon as you update the content list, so all you need to do is check periodically for the availability of the live stream and then add the poster item to the poster list:


screen=createobject("roposterscreen")
screen.show()
test=[{shortdescriptionline1:"test"},{shortdescriptionline1:"west"},{shortdescriptionline1:"best"}]
screen.setcontentlist(test)
test.unshift({shortdescriptionline1:"vest"})
screen.setcontentlist(test)


so you could have your main loop:

timer=createobject("rotimespan")
while true
msg=wait(100,port)

if timer.totalseconds() > 60 then
posteritem=checkforlivestream()
if type(posteritem) = "roassociativearray" then
posterlist.unshift(posteritem)
screen.setcontentlist(posterlist)
else 'condition here is that there is no live stream available
if posterlist[0].livestream=true then 'here we check if the poster item for a live stream is in the current list so we can remove it from the list
posterlist.shift() 'remove poster item from the list
screen.setcontentlist(posterlist)
end if
end if
end if
timer.mark()
end if


and


function checkforlivestream() as object
.... code to check for livestream goes here
if livestream=true then
....code to build Associative Array for live stream goes here
posteritem=livestreamAA
posteritem.livestream=true 'add this to your poster item so that it is unique and easy to remove from posterlist
else
posteritem=-1
end if
return posteritem
end function
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
jnicholas
Visitor

Re: Dynamically updating poster images

I have the live connection working great now, thanks for your help jbrave and rokuchris. I have noticed one odd thing though. The screen that is polling for live is a Springboard that has text indicating that live isn't on right now but you can wait here for the live show to start. There is no action for the user to take except they can decide to hit up to go back to other content, but the screen won't listen for the up event unless I add a button. I don't really have anything for the button to do so is there a way to have it listen for the up button without adding a visible button? Or should I be using a different screen type here?
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: Dynamically updating poster images

"jnicholas" wrote:
I have the live connection working great now, thanks for your help jbrave and rokuchris. I have noticed one odd thing though. The screen that is polling for live is a Springboard that has text indicating that live isn't on right now but you can wait here for the live show to start. There is no action for the user to take except they can decide to hit up to go back to other content, but the screen won't listen for the up event unless I add a button. I don't really have anything for the button to do so is there a way to have it listen for the up button without adding a visible button? Or should I be using a different screen type here?


That's a known issue. You must add at least one button. Usually I just add a button labeled "Back" that closes the screen if the user selects it.
0 Kudos
jbrave
Channel Surfer

Re: Dynamically updating poster images

Why not put an "OK" button on the screen that closes it?

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
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.