我有一个http地址来加载与时间戳变化的图像。
例如xxx.com?time=192186577
我可以使用Poster对象来实时刷新图像内容吗?如果海报不支持它,我可以使用另一个对象吗?请帮帮我。
我正在实现Poster组件的代码
<?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发布于 2021-08-25 19:52:08
您可以通过向海报图像的url字符串添加一个参数来实现这一点。在roku上,生成时间戳并将其添加到url中。
dt=createobject("roDateTime") value=dt.AsSeconds() transferstringurl=transferstringurl+"?ts="+value.toStr()
ie - http://myservername.com/images/myposter.jpg?ts=1494302631
或者,您可以修改头文件--(不确定它在roku的客户端是否有效,但需要在服务器端设置) Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0
你需要在每次想要更改海报时更新项目的hdposterurl和sdposterurl,并且需要使用新数据更新所有显示的内容列表,无论它们的屏幕是否可见,以确保它将新图像传播到所有内容(为了安全起见)-或者可能不会传播,这取决于代码的设置。
这实际上解决了我的问题
https://stackoverflow.com/questions/68422329
复制相似问题