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: 
tim_beynart
Channel Surfer

RAF doesn't clear ad when back button pressed during ad

I'm integrating RAF with server side ads. I've followed the docs to the letter, but for some reason when I press the BACK button on the remote during an ad, the screen goes black and "Ad 1 of 1" is stuck in the upper left hand corner. I don't see any methods in RAF that allow me to close the ad renderer. 
When I implement stitchedAdHandledEvent, adExited is always false, even after a back button press.

Any ideas?
0 Kudos
9 REPLIES 9
RokuNB
Roku Guru

Re: RAF doesn't clear ad when back button pressed during ad

Can you provide some more detail on how you are using RAF?
You are doing SSAI (server-side ad stitching)?
Is that in "RSG mode", running event loop in a Task - or in some other way (e.g. SDK1/roVideoPlayer, event loop in main etc)?
If you can post code snippets, that may help as well.
0 Kudos
tim_beynart
Channel Surfer

Re: RAF doesn't clear ad when back button pressed during ad

This is all BrightScript, no SceneGraph. roVideoPlayer is the mechanism for playback.
I'm using RAF according to the docs. The content is HLS with ads stitched in.
The back button and UI works as expected when used outside of a RAF ad.

We import our ad beacons like this:
m.adIface = Roku_Ads()
m.adIface.setDebugOutput(true)
m.adIface.enableAdBufferMessaging(false,false)
m.adIface.setAdPrefs(false,0)
m.adIface.enableNielsenDAR(true)
m.adIface.stitchedAdsInit({a bunch of ad beacons})





The message loop looks something like this:
Function CustomVideoPlayer_ListenForEvents()
 m.ShouldExit = false
 while NOT m.shouldExit
       msg = wait(100, m.messagePort) 
        If Type(msg) = "roImageCanvasEvent" Then
            ?  "[APP VIDEO] roImageCanvasEvent index: "; msg.GetIndex()
            If msg.isRemoteKeyPressed()
                index = msg.GetIndex()
               ? "Remote button pressed: " + index.tostr()
                If index = 0 OR index = 23
                    m.shouldExit = true
                    exit while
 ... snip ...
curAd = m.RAF.adIface.stitchedAdHandledEvent(msg, m.videoScreen)
    if curAd <> invalid
        ? "RAF current ad event fired."
          ? curAd
        ? " ********* "
    end if
...snip...
 end while
 if m.videoScreen <> invalid
    m.videoScreen.close()
 end if
 if m.uiScreen <> invalid :m.uiScreen.close():end if
 m.videoScreen = invalid
 m.uiScreen = invalid
End Function



debug output when back button pressed:


RAF current ad event fired.
<Component: roAssociativeArray> =
{
    adcompleted: false
    adexited: false
    adindex: 1
    adpodindex: 1
    evthandled: true
}
 ********* 
[APP VIDEO] roImageCanvasEvent index:  0
Remote button pressed: 0

0 Kudos
RokuNB
Roku Guru

Re: RAF doesn't clear ad when back button pressed during ad

"tim_beynart" wrote:
I'm integrating RAF with server side ads. I've followed the docs to the letter, but for some reason when I press the BACK button on the remote during an ad, the screen goes black and "Ad 1 of 1" is stuck in the upper left hand corner. I don't see any methods in RAF that allow me to close the ad renderer. 
When I implement stitchedAdHandledEvent, adExited is always false, even after a back button press.

Any ideas?

I don't think you have followed "the docs to the letter". See the "Server-Side Ad Insertion Example" snippet in https://sdkdocs.roku.com/display/sdkdoc ... +Framework

It tells you to first let RAF handle the event via stitchedAdHandledEvent() - and only if it returns .evtHandled = false, then that is a msg for you. Instead, from skimming the code i see you handle the event first - and if it's a Back button then you exit the loop. It shouldn't be surprising if RAF does not clear its UI, it never got a chance of handling the Back event
0 Kudos
tim_beynart
Channel Surfer

Re: RAF doesn't clear ad when back button pressed during ad

Do you realize your response could be interpreted as condescending? Otherwise, thanks for the clarification. 
0 Kudos
destruk
Binge Watcher

Re: RAF doesn't clear ad when back button pressed during ad

Having to deal with customers all day long is a very trying experience.  I'd cut them a little slack - at least they answer.
0 Kudos
tim_beynart
Channel Surfer

Re: RAF doesn't clear ad when back button pressed during ad

Point taken. Thanks for the help, Roku NB. 😄
0 Kudos
RokuNB
Roku Guru

Re: RAF doesn't clear ad when back button pressed during ad

"tim_beynart" wrote:
Do you realize your response could be interpreted as condescending? Otherwise, thanks for the clarification. 

No - i did not realize this at the time, Tim. My apologies for my uncouth manners. I am software developer and answering forum questions is not part of my job description, nor am i encouraged doing it, nor am getting credit for that.

In fact, none of the Roku-names you see replying in the dev.forum these days do that as part of their job. Rather, we are volunteers that like to help other developers. Some of us do it, because we believe that a thriving developer community is crucial to a platform success. I do it also because i have learned a lot from other developers in the forum and want to "pay it forward".

For a courteous service, please direct your questions to https://developer.roku.com/en-ca/contact - we have a team of friendly and very polite "Partner Success" managers behind it.
tim_beynart
Channel Surfer

Re: RAF doesn't clear ad when back button pressed during ad

Thanks for clarifying, it's hard to tell what the deal is with these forums. And of course text on a screen is easy to misinterpret, apologies for my unprofessional griping.
BTW I found the documentation for RAF a little confusing. It's hard to tell what applies to SSAI and what applies to client side ads.
In the end, your suggestion worked, thanks. 
0 Kudos
RokuNB
Roku Guru

Re: RAF doesn't clear ad when back button pressed during ad

"tim_beynart" wrote:
BTW I found the documentation for RAF a little confusing. It's hard to tell what applies to SSAI and what applies to client side ads.

Yes, the SSAI was the road less traveled till recently - kudos to you for persevering over unclarities and making it work! We could certainly improve by publishing example code - and if i remember the "ad structure" currently does not list the differences between what it uses client vs server-stiched ads (much less fields should be listed "required" for SSAI)

Can you create a new topic with your feedback re RAF documentation - this and more you can think of (be specific if you remember, even minor things)? Plus chance of others chime in, so i can collect and try addressing the issues.
0 Kudos