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: 
balbant
Streaming Star

Can Play RAF ads in small sticky player (450*253)?

I have designed and implemented the sticky player (player size are width 450 and height 253), now I have added the RAF for play the Ads in this sticky player but ads are playing in full screen. Could you please suggest to play Ads in this sticky player size width 450 and height 253?
0 Kudos
1 REPLY 1
PriApocalypse
Channel Surfer

Re: Can Play RAF ads in small sticky player (450*253)?

Hello @balbant  I've spent a lot of time figuring out a way to handle the mini player with RAF. For the project I am working on, it's not viable to use the SGDEX framework due to the significant rework required for integration. SGDEX is an option, but I'll provide a solution using the regular RAF. I believe you are using the showAds() function from the RAF library. You need to create an overlay layer for your view and pass it for showAds(), the view usually is video.getParent(). By doing this, you ensure that the new overlay is on top of the video view. You can then resize it using the overlay scale. In this example, I am using 0.58 of the full 1080 size, but you can adapt it to your size. The translation 0,0 means it will be positioned at the same x and y coordinates as the parent. You can also choose different x and y coordinates if you want to move it, but I believe you want this on the same video player at a reduced size. Here is the example of what I said : 

 

m.overlayNode = createObject("roSGNode", "Group")
view = video.getParent()
if isFullScreen = false
    ' Create a new overlay node to display ads
    m.overlayNode.translation = [0, 0] ' Adjust as needed to position over the video
    m.overlayNode.scale = [0.58, 0.58] ' Adjust the scale as needed
    ' Add the overlay node to the top of the screen (or relevant parent)
    screen = view
    screen.appendChild(m.overlayNode)
end if

'Your Call for preroll ads
video.control = "stop"
if m.top.isFullScreen = true
    keepPlaying = RAF.showAds(adPods, invalid, view)
else
    keepPlaying = RAF.showAds(adPods, invalid, m.overlayNode)
end if

 

I hope this helps you. You will probably face issues with RAF grabbing focus for the overlay but a workaround would be to create a custom ads callback and use RAF.SetTrackingCallback function to identify when the ad started for you to set Focus for your video root parent. It's tricky since RAF needs the focus to itself to handle a lot of internal important stuff.



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.