Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
manishDev
Level 7

Video to Ad transition screen back button issue (Scene graph)

Hi,

Every time a user selects a video item on the grid screen, I take the content to the video player (a separate node). The video player before playing the content, passes to a task node whose job is to fetch and play raf ads and then continue with the content. Both playing on the same video player node one after the other.

Issue: there is a transition time between video item selected and raf ad starting to play. If I press the back key during this transition time, the screen comes to the grid screen without focus and the ad starts playing in the background. Press back again, ad stops and focus comes to the grid screen. Any idea where I am going wrong here? Back key on the running ad and running content works just fine.
0 Kudos
7 Replies
tim_beynart
Level 7

Re: Video to Ad transition screen back button issue (Scene graph)

RAF probably has focus during that task activity. You need to add code in your RAF task loop to force focus onto the Video node to handle the back button.
0 Kudos
Roku Employee
Roku Employee

Re: Video to Ad transition screen back button issue (Scene graph)

I believe what's happening is, when Back is pressed RAF has not taken then input focus yet but is initializing. If it had taken the focus, Back would not exit the app's details screen to go back to grid screen. And right after that happens, RAF has deployed its UI and grabbed the input focus. So it is a race condition. To avoid chance of it happening, how about .setFocus(false) in that screen before calling RAF - and then .SetFocus(true) after it returns?
0 Kudos
manishDev
Level 7

Re: Video to Ad transition screen back button issue (Scene graph)

Thanks all,

I figured the solution. It was rather simple but took some drilling down the fields of elements to fix it.

P.S: The Task node documentation mentions state field is case sensitive and example has been shows in capitals. Actually, all the read-only state values are smalls and not capitals.
0 Kudos
abhishek
Level 7

Re: Video to Ad transition screen back button issue (Scene graph)

@ROKUNB

Setting the focus to false on a node can lead to unexpected behavior as per documentation https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeFocus

Can you please clarify this.
0 Kudos
Roku Employee
Roku Employee

Re: Video to Ad transition screen back button issue (Scene graph)

"manishDev" wrote:
P.S: The Task node documentation mentions state field is case sensitive and example has been shows in capitals. Actually, all the read-only state values are smalls and not capitals.

That is confusing, i agree. Here is how it works:

  • when you are setting the control field, the operation is case-insensitive, i.e. whether "RUN" or "run" makes no difference

  • when you are getting a field, e.g. state - it necessarily has to return one of the two, either lower-case or upper-case. It returns lowercase "run"
0 Kudos
Roku Employee
Roku Employee

Re: Video to Ad transition screen back button issue (Scene graph)

"abhishek" wrote:
@ROKUNB

Setting the focus to false on a node can lead to unexpected behavior as per documentation https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeFocus

Can you please clarify this.

That is true, turns out setFocus(false) does not have well-defined behavior ATM. So to future-proof your code, a better choice would be to .setFocus(true) on some other node ("input sink" of sorts), where pressing Back won't cause damage.
0 Kudos
abhishek
Level 7

Re: Video to Ad transition screen back button issue (Scene graph)

"RokuNB" wrote:
"abhishek" wrote:
@ROKUNB

Setting the focus to false on a node can lead to unexpected behavior as per documentation https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeFocus

Can you please clarify this.

That is true, turns out setFocus(false) does not have well-defined behavior ATM. So to future-proof your code, a better choice would be to .setFocus(true) on some other node ("input sink" of sorts), where pressing Back won't cause damage.

Thanks for your reply. It's a better way of implementation.
0 Kudos