I feel like there's something I'm missing. I'd like to fire off an ad between videos in a playlist, but I can't find a straight-forward way to do it. I put together this hack that sort of works:
if msg.GetField() = "position" then ' keep track of where we reached in content' curPos = msg.GetData() ' Start ad at beginning of video' if curIndex <> video.contentIndex print "playing video:" curIndex = video.contentIndex print curIndex ' if ad has not played yet' if adPlayed[video.contentIndex] <> true then adPlayed[video.contentIndex] = true ' check for mid-roll ads' adPods = RAF.getAds() if adPods <> invalid and adPods.count() > 0 print "PlayerTask: mid-roll ads, stopping video" 'ask the video to stop - the rest is handled in the state=stopped event below' video.control = "stop" end if end if end if end if
basically, I'm just checking if the current video id has changed and dropping in the ad. However, this allows for a flash of the next video to play before the ad loads. Is there anyway to have it more seamless?
One more issue I notice is that hitting that "<-" button while an ad is playing won't actually stop the ad. It appears RAF isn't recognizing the back key press... though, if I run it as a pre-roll, I can see in the logs that the key press is registered, and everything works fine. It's only in the loop that issue happens. Any thoughts?
If you are using scenegraph and you want to know when it moves to the next video you need to observe the "contentIndex" field of the video component. That way the "playing" State will fire when the first video plays or any video is resumed, the video contentindex will fire when it moves to videos 2, 3, 4, 5, etc, and the "finished" State will fire when the playlist is done. I haven't looked at the RAF code, or which version you're using, so it might work differently.