tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017
10:44 AM
RAF and the Back Button... Focus Problems
I'm struggling with RAF, SSAI, and the back button. I will be the first to admit that I am confused by how SG handles remote events (for example, why does RAF steal focus and not trigger onKeyPress observers upstream?).
I have implemented stitchedAdhandledEvent in an event loop, inside of a task.
Problem 1:
During an ad, if I click the back button I see this debug info:
and I can see that RAF reports the adexited:true
However, I must hit the back button again for my home scene to detect the keypress and close the video. I assume I am supposed to hack an observer upstream to close the video player manually using the information provided by RAF?
Problem 2:
During content, The back button is swallowed completely by RAF. No debug info, nothing. The content just keeps playing as if the button was never pressed. The stitchedAdHandledEvent logs this
Attempts to fix:
So far I have tried to force focus on the video node using m.videoplayer.setFocus(true) inside of the RAF event loop, but this does not work as expected. The video does indeed close and my logic runs to show the previous screen, but focus is not assigned as expected to some buttons on this screen.
Can anyone provide an RAF SSAI example in SeneGraph that illustrates how to make the back button work as expected?
I have implemented stitchedAdhandledEvent in an event loop, inside of a task.
Problem 1:
During an ad, if I click the back button I see this debug info:
rafrndr-onKeyEvent() - key: back
rafrndr-onkeyevent() - keycode: 0
and I can see that RAF reports the adexited:true
RAF cur ad > <Component: roAssociativeArray> =
{
adcompleted: false
adexited: true
adindex: 1
adpodindex: 1
evthandled: true
}
However, I must hit the back button again for my home scene to detect the keypress and close the video. I assume I am supposed to hack an observer upstream to close the video player manually using the information provided by RAF?
Problem 2:
During content, The back button is swallowed completely by RAF. No debug info, nothing. The content just keeps playing as if the button was never pressed. The stitchedAdHandledEvent logs this
RAF cur ad > <Component: roInvalid>
Attempts to fix:
So far I have tried to force focus on the video node using m.videoplayer.setFocus(true) inside of the RAF event loop, but this does not work as expected. The video does indeed close and my logic runs to show the previous screen, but focus is not assigned as expected to some buttons on this screen.
Can anyone provide an RAF SSAI example in SeneGraph that illustrates how to make the back button work as expected?
5 REPLIES 5
tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017
12:21 PM
Re: RAF and the Back Button... Focus Problems
Is there an official working example of SceneGraph RAF using SSAI anywhere?
tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017
01:38 PM
Re: RAF and the Back Button... Focus Problems
I sort of figured it out, in case anyone stumbles on this thread.
My home scene monitors the video state, and will hide the video node and show the details screen when state="stopped", so the following event loop for RAF works for my needs:
My home scene monitors the video state, and will hide the video node and show the details screen when state="stopped", so the following event loop for RAF works for my needs:
m.playing = true
while m.playing
msg = wait(0, port)
? "RAF >",type(msg),msg.getField(),msg.getData()
curAd = invalid
curAd = m.raf.stitchedAdHandledEvent(msg, {sgNode:m.videoplayer,port : port})
if curAd <> invalid
'detect ad exit and nuke loop
if curAd.adExited
? "ad exited"
m.videoplayer.control="STOP"
m.playing = false
exit while
end if
else if msg.getField()="keypressed" and msg.getData()=0
? "BACK BUTTON PRESSED"
m.playing = false
m.videoplayer.control="STOP"
exit while
end if
end while
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017
07:39 PM
Re: RAF and the Back Button... Focus Problems
In your "if curAd <> Invalid" branch, make sure to add
if curAd.adCompleted:
' ad rendering may reset focus, make sure focus is set properly when not rendering an ad '
video.setFocus(true)
end if
tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017
07:42 AM
Re: RAF and the Back Button... Focus Problems
Thanks RokuNB. I think I finally got my head around this. I am a little confused as to why RAF swallows the back button entirely, that seems like an event that would bubble. Is this behavior necessary to support interactive ads (e.g. Brightline)?
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2017
01:46 PM
Re: RAF and the Back Button... Focus Problems
"tim_beynart" wrote:
I am a little confused as to why RAF swallows the back button entirely, that seems like an event that would bubble. Is this behavior necessary to support interactive ads (e.g. Brightline)?
Because all your keys are belong to us? 8-)
All remote input during an ad run are consumed by RAF, not only Back. And yes, interactive ads are part of the picture.
It would be more intuitive in CSAI case, re SSAI I understand the flummox. It's one of those edge cases that can be argued either way.