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: 
justint
Visitor

RAF and VMAP support

I have looked at the several posted related but they did nothing to alleviate my issues.

RAF 1.4
SF version 7.0 (9021)

I have the below code:


function createVideoScreen()
screen = CreateObject("roVideoScreen")
screen.SetLoop(true)
screen.SetPositionNotificationPeriod(1)

return screen
end function

sub showVideoScreen(screen As Object, episode As Object)
port = CreateObject("roMessagePort")
episode = getStreamForEpisode(episode, webClient())

playbackPosition = 0

screen.SetContent(episode)
screen.SetMessagePort(port)

shouldUseRAFAdsFallback = false
maxRetries = 2

adIface = Roku_ads()
adIface.SetAdPrefs(shouldUseRAFAdsFallback, maxRetries)

adIface.setAdUrl("https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpost&cmsid=496&vid=short_onecue&correlator=")

adPods = adIface.getAds()

'Play pre-roll
shouldPlayContent = adIface.showAds(adPods)

if shouldPlayContent then
screen.Show()
end if

while shouldPlayContent
msg = wait(0, port)

if msg.isPlaybackPosition() then
episode.PlayStart = msg.GetIndex()

adPods = adIface.getAds(msg)

if adPods <> invalid and adPods.Count() > 0
print "Ad break hit @ " episode.PlayStart

screen.Close()
shouldPlayContent = adIface.showAds(adPods)

if shouldPlayContent
screen = createVideoScreen()
screen.SetMessagePort(port)
screen.SetContent(episode)
screen.Show()
end if
end if
end if

if msg.isScreenClosed()
shouldPlayContent = false
end if
end while

screen.Close()
end sub

function getStreamForEpisode(episode As Object, client As Object) As Object
stream = client.getUrlForContent(episode.contentId)

episode.Stream = {
url: stream.url,
bitrate: 0,
quality: false
}

episode.PlayStart = 0
episode.StreamFormat = "hls"
episode.adUrl = stream.vmapUrl

return episode
end function


But the adpod count is 0. Works on Google IMA's video inspector and any of the ads that aren't a playlist work. Looking on some input on why this isn't working and how to make it work.

In the above example I am using the google ima test ad directly.
0 Kudos
1 REPLY 1
TheEndless
Channel Surfer

Re: RAF and VMAP support

There's something odd about that URL. It explicitly specifies VMAP as the output format, but it's returning an XML playlist, instead. As far as I'm aware RAF doesn't support playlists, so you'll likely either need to parse the playlist yourself and pass the individual VAST URLs to RAF at the appropriate times, or figure out why you're not getting a VMAP response back (which RAF does support).
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
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.