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

Scene Graph Video Player - notificationInterval Not Working

Hi All,

While watching a video I'd like to display the timecode (hh:mm:ss:ff) in a label on the video player while the video is playing. In order to do this I'm observing the "position" field of the scene graph video player (see documentation here). In my code, no matter what I set the "notificationInterval" value to, it only executes my observer function every .5 seconds. 

I downloaded the Simple_Grid_and_Video.zip reference code (here) and added the following lines of code to demonstrate the problem

' ********** Copyright 2016 Roku Corp.  All Rights Reserved. ********** 
 ' inits grid screen
 ' creates all children
 ' sets all observers 
Function Init()
    ' listen on port 8089
    ? "[HomeScene] Init"

    'main grid screen node
    m.GridScreen = m.top.findNode("GridScreen")
    'video player node
    m.videoPlayer = m.top.findNode("videoPlayer")
    
    'MY ADDED CODE----------------------------------------------
    m.videoPlayer.ObserveField("position", "positionChanged")
    m.videoPlayer.notificationInterval = 0.1
    '----------------------------------------------------------- 

    'added handler on item selecting event in grid screen
    m.top.observeField("rowItemSelected", "OnRowItemSelected")
    
    ' loading indicator starts at initializatio of channel
    m.loadingIndicator = m.top.findNode("loadingIndicator")
End Function 

'MY ADDED CODE----------------------------------------------
Function positionChanged()
    ? m.videoPlayer.position
End Function
'-----------------------------------------------------------



Can anyone offer any insight? I'm sure I'm overlooking something.

Many Thanks in Advance!
0 Kudos
2 REPLIES 2
belltown
Roku Guru

Re: Scene Graph Video Player - notificationInterval Not Working

It looks like the resolution of the notificationInterval and of the position is only about 0.5 secs. If that's the case, you won't be able to set notificationInterval to less than 0.5 secs; even if you could the position would only be accurate to within 0.5 secs. You can set it to something larger, but still with about 0.5 secs of resolution.

I don't think it was intended to be used to display a timecode label to within a fraction of a second. Position notifications have typically been used to trigger saving bookmark information, which doesn't need that level of accuracy.

You can use a Timer node to trigger more frequent updates, doing "fake" timecode updates that you sync up with the position every half second or so.
0 Kudos
firemaple
Visitor

Re: Scene Graph Video Player - notificationInterval Not Working

Thanks Belltown! I was hoping that there was a way to get the position resolution to be smaller but your idea about using a timer node and syncing it up with the position every .5 seconds is brilliant. I'm going to give that a try. I appreciate the help!
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.