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

pre roll ad in mini video player using RAF

I am trying to play pre roll ad using RAF in small video player i.e video player window is 25% smaller (height and width) of TV screen but the issue I am facing is...as soon as player starts to playing ad, it alwas plays ad in full screen and it is not respecting height width which supplied by me to player (video node). I tried changing height width of parent view of video node but it did not helped me. Can you please help me on this and can you suggest me how should I acheive this? 

0 Kudos
2 REPLIES 2
PriApocalypse
Channel Surfer

Re: pre roll ad in mini video player using RAF

Hello @JalpaWhiz 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 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.


JalpaWhiz
Channel Surfer

Re: pre roll ad in mini video player using RAF

Thanks a lot bro you done a million dollar job.

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.