DadOfTwo
8 years agoVisitor
How to determine image is cached on OS?
Hi all
Am looking at the way Brightscript auto caches images and if it's possible to determine programmatically if the image being loaded into a Roku native list (via itemComponentName) is loading from the server or loading via the OS cache.
Observing the `loadStatus` on the Poster fires the exact same results.
We're taking a look at this cause we're seeing inconsistent behaviour with an Animation fade up on loaded images into a RowList. Images loaded via the server fade up as expected. Images loaded from the cache fade up a lot faster, visually around 4 times faster.
If we force the images to load via the server each time, via a cache buster, the images fade up as expected.
Here's an example of the code we're using for the itemComponentName:
And the script:
Am looking at the way Brightscript auto caches images and if it's possible to determine programmatically if the image being loaded into a Roku native list (via itemComponentName) is loading from the server or loading via the OS cache.
Observing the `loadStatus` on the Poster fires the exact same results.
We're taking a look at this cause we're seeing inconsistent behaviour with an Animation fade up on loaded images into a RowList. Images loaded via the server fade up as expected. Images loaded from the cache fade up a lot faster, visually around 4 times faster.
If we force the images to load via the server each time, via a cache buster, the images fade up as expected.
Here's an example of the code we're using for the itemComponentName:
<?xml version="1.0" encoding="utf-8" ?>
<component name="RowListItem" extends="Group" >
<script type="text/brightscript" uri="pkg:/components/view/RowListItem.brs" />
<interface >
<field id="itemContent" type="node" onChange="showContent"/>
</interface>
<children>
<Poster id="itemPoster" />
<Animation id="fadeAnimation" duration="1.5" optional="true" repeat="false" easeFunction="linear" >
<FloatFieldInterpolator id="fadeInterp" key="[ 0.0, 0.5, 1.0 ]"
fieldToInterp="itemPoster.opacity" />
</Animation>
</children>
</component>
And the script:
sub init()
m.top.findNode("itemPoster").translation = [10, 10]
end sub
function posterLoadedStateHandler (status) as Void
if (status.getData() = "ready")
fadeImageUp()
m.top.findNode("itemPoster").unobserveField("loadStatus")
end if
end function
function fadeImageUp () as Void
m.top.findNode("itemPoster").opacity = 0
m.top.FindNode("fadeInterp").keyValue = [0.0, 0.5, 1.0]
m.top.FindNode("fadeAnimation").control = "START"
end function
sub showContent()
if (m.top.height > 0 AND m.top.width > 0)
m.top.findNode("itemPoster").observeField("loadStatus", "posterLoadedStateHandler")
m.top.findNode("itemPoster").uri = m.top.itemcontent.HDPOSTERURL
m.top.findNode("itemPoster").width = m.top.width
m.top.findNode("itemPoster").height = m.top.height
end if
end sub