I have 1 http address to load images that change with timestamp.
For example xxx.com?time=192186577
Can I use a Poster object to do this real-time refresh of the image content? If the poster doesn't support it, can I use another object? Please give me some help.
The code I'm implementing the Poster component
<?xml version="1.0" encoding="utf-8" ?>
<component name="posterScene" extends="Scene" >
<script type="text/brightscript" >
<!-- m.poster.ObserveField("loadStatus", "changetext") -->
<![CDATA[
sub init()
m.timer = m.top.findNode("exampleTimer")
m.timer.ObserveField("fire", "changetexta")
m.timer.control = "start"
m.mirrorUrl = "http://192.168.11.6:4998/screenmirroring"
m.poster = m.top.findNode("channelbugPoster")
m.top.setFocus(true)
end sub
sub changetexta()
time = CreateObject("roDateTime")
second = time.AsSeconds()
milisecond = time.GetMilliseconds()
timestampString = second.ToStr() + milisecond.ToStr()
mirrorUrl=m.mirrorUrl+"?ts="+timestampString
print(mirrorUrl)
m.poster.uri = mirrorUrl
end sub
]]>
</script>
<children>
<Poster
id="channelbugPoster"
uri="http://192.168.11.6:4998/screenmirroring?ts=1627150215328"
width="1080"
height="720"
translation="[0,0]" />
<Timer
id = "exampleTimer"
repeat = "true"
duration = "0.03" />
</children>
</component>
Main.brs
'********** Copyright 2015 Roku Corp. All Rights Reserved. **********
sub Main()
showChannelSGScreen()
end sub
sub showChannelSGScreen()
print "in showChannelSGScreen"
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("posterScene")
screen.show()
while(true)
msg = wait(0, m.port)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end while
end sub
You can probably do this by adding a parameter to the url string for the poster image. On roku, generate a timestamp and add it to the url.
dt=createobject("roDateTime") value=dt.AsSeconds() transferstringurl=transferstringurl+"?ts="+value.toStr()
ie - http://myservername.com/images/myposter.jpg?ts=1494302631
Or you could modify the headers - (not sure if it works from roku's client side, but it'd be something to set on the server side) Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0
You'd need to update the hdposterurl and sdposterurl for the item every time you want the poster to change, and you'll need to update all displayed content lists with the new data whether their screens are visible or not, to be sure it propagates the new image to everything (to be on the safe side) - or maybe you won't depending on how your code is set.
This actually solved my problem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.