Player flickers when playback to Midroll ad transition . please help me.
while keepPlaying
msg = wait(0, port)
if type(msg) = "roSGNodeEvent"
if msg.GetField() = "position" then
' keep track of where we reached in content
m.curPos = msg.GetData()
' check for mid-roll ads
if(m.curPos >= duration - 10 and not videoCompleted)
videoCompleted = true
end if
adPods = RAF.getAds(msg)
if adPods <> invalid and adPods.count() > 0
print "AdsEventTask: mid-roll ads, stopping video"
'ask the video to stop - the rest is handled in the state=stopped event below
video.control = "stop"
' m.adTimes[key.tostr()] = keepPlaying
for i = 0 to m.adMarkers.Count() - 1
if m.adMarkers[i].startTime = adPods.rendertime * 1000
m.adMarkers.Delete(i)
exit for
end if
end for
m.top.adPositions = m.adMarkers
end if
else if msg.GetField() = "control" then
control = msg.GetData()
if video.state = "stopped" and video.visible = false
exit while
end if
else if msg.GetField() = "duration" then
duration = msg.GetData()
else if msg.GetField() = "state" then
curState = msg.GetData()
print "AdsEventTask: state = "; curState
if curState = "stopped" then
if adPods = invalid or adPods.count() = 0 then
exit while
end if
print "AdsEventTask: playing midroll/postroll ads"
keepPlaying = RAF.showAds(adPods, invalid, view)
adPods = invalid
if isPlayingPostroll then
exit while
end if
if keepPlaying then
print "AdsEventTask: mid-roll finished, seek to "; stri(m.curPos)
video.visible = true
video.seek = m.curPos
video.control = "play"
video.setFocus(true) 'important: take the focus back (RAF took it above)
else
m.top.backOut = true
exit while
end if
else if curState = "finished" then
print "AdsEventTask: main content finished"
' render post-roll ads
adPods = RAF.getAds(msg)
if adPods = invalid or adPods.count() = 0 then
exit while
end if
print "AdsEventTask: has postroll ads"
isPlayingPostroll = true
' stop the video, the post-roll would show when the state changes to "stopped" (above)
video.control = "stop"
end if
end if
end if
end while