Your Digital Media Has Never Looked So Good

 
tim_beynart
Topic Author
Posts: 141
Joined: Wed Jul 15, 2015 8:30 am

RAF and the Back Button... Focus Problems

Thu Aug 24, 2017 10:44 am

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:

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?
 
tim_beynart
Topic Author
Posts: 141
Joined: Wed Jul 15, 2015 8:30 am

Re: RAF and the Back Button... Focus Problems

Thu Aug 24, 2017 12:21 pm

Is there an official working example of SceneGraph RAF using SSAI anywhere?
 
tim_beynart
Topic Author
Posts: 141
Joined: Wed Jul 15, 2015 8:30 am

Re: RAF and the Back Button... Focus Problems

Thu Aug 24, 2017 1:38 pm

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:
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
 
User avatar
RokuNB
Posts: 254
Joined: Fri Mar 31, 2017 2:22 pm

Re: RAF and the Back Button... Focus Problems

Thu Aug 24, 2017 7:39 pm

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
Topic Author
Posts: 141
Joined: Wed Jul 15, 2015 8:30 am

Re: RAF and the Back Button... Focus Problems

Fri Aug 25, 2017 7:42 am

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)?
 
User avatar
RokuNB
Posts: 254
Joined: Fri Mar 31, 2017 2:22 pm

Re: RAF and the Back Button... Focus Problems

Sat Aug 26, 2017 1:46 pm

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.

Who is online

Users browsing this forum: No registered users and 3 guests