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
' 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"