Skip to main content
Version: 11.8.0

How to measure the time-to-first-frame on Roku

The time-to-first-frame, also known as the start-up time, is the time between the moment where playback is requested and the moment where the first frame is rendered.

To measure it, measure the time between the play event and the playing event.

Usage

On Roku, you measure the elapsed time with a roTimespan.

sub Init()
...
m.timespan = CreateObject("roTimespan")
m.THEOplayer.callFunc("addEventListener", "play", m.top, "onPlay")
m.THEOplayer.callFunc("addEventListener", "playing", m.top, "onPlaying")
...
end sub

sub onPlay()
m.timespan.Mark()
end sub

sub onPlaying()
print "Time-to-first-frame: "; m.timespan.TotalMilliseconds()
end sub

If you use autoplay, start the measurement on the sourcechange event instead of the play event. Otherwise you miss the start-up time between setting the source and the player calling play():

m.THEOplayer.callFunc("addEventListener", "sourcechange", m.top, "onSourceChange")

sub onSourceChange()
m.timespan.Mark()
end sub