Forum Discussion
gsarath
10 years agoVisitor
I am able to resume the playback after midroll with the below mentioned code changes:
port = CreateObject("roMessagePort")
contentVideoScreen = CreateObject("roVideoScreen")
contentVideoScreen.setMessagePort(port)
adIface = Roku_Ads()
adUrl = "file://pkg:/images/ads.xml"
adIface.setAdUrl(adUrl)
ads = adIface.getAds()
if ads <> invalid and ads.count() > 0 ' to play pre roll
shouldPlayContent = adIface.showAds(ads)
end if
videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = bitrates
videoclip.StreamUrls = urls
videoclip.StreamQualities = qualities
videoclip.StreamFormat = StreamFormat
videoclip.Title = title
contentVideoScreen.SetContent(videoclip)
contentVideoScreen.show()
curPos = 0
while shouldPlayContent
videoMsg = wait(0, contentVideoScreen.GetMessagePort())
adPods = adIface.getAds(videoMsg)
if adPods <> invalid and adPods.Count() > 0
contentVideoScreen.Close() ' stop playback of content
shouldPlayContent = adIface.showAds(adPods) ' render current ad pod
if shouldPlayContent
' *** Insert client app’s resume-playback code here
port = CreateObject("roMessagePort")
contentVideoScreen = CreateObject("roVideoScreen")
contentVideoScreen.setMessagePort(port)
contentVideoScreen.PlayStart = curPos
contentVideoScreen.SetContent(videoclip)
contentVideoScreen.show()
end if
end if
' *** Insert client app’s video event handler code here
if type(msg) = "roVideoScreenEvent"
print "showVideoScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed() then 'ScreenClosed event
print "Closing video screen"
exit while
else if msg.isFullResult() then
print "play back completed"
exit while
else if msg.isPaused() then
print("video Paused")
else if msg.isResumed() then
print("video Resumed")
else if msg.isPartialResult()
print "playback interrupted"
exit while
else if msg.isRequestFailed()
print "request failed - error: "
exit while
else if msg.isPlaybackPosition() then
print("playback position="+str(msg.GetIndex()))
curPos = msg.GetIndex()
end if
end if
end while
After completion of midroll ad, the main video content resumes. But I am not able to see only playbackposition event and able to see all the other events(pause/resume/FullResult/PartialResult). Can some one please specify is there anything I have missed?
port = CreateObject("roMessagePort")
contentVideoScreen = CreateObject("roVideoScreen")
contentVideoScreen.setMessagePort(port)
adIface = Roku_Ads()
adUrl = "file://pkg:/images/ads.xml"
adIface.setAdUrl(adUrl)
ads = adIface.getAds()
if ads <> invalid and ads.count() > 0 ' to play pre roll
shouldPlayContent = adIface.showAds(ads)
end if
videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = bitrates
videoclip.StreamUrls = urls
videoclip.StreamQualities = qualities
videoclip.StreamFormat = StreamFormat
videoclip.Title = title
contentVideoScreen.SetContent(videoclip)
contentVideoScreen.show()
curPos = 0
while shouldPlayContent
videoMsg = wait(0, contentVideoScreen.GetMessagePort())
adPods = adIface.getAds(videoMsg)
if adPods <> invalid and adPods.Count() > 0
contentVideoScreen.Close() ' stop playback of content
shouldPlayContent = adIface.showAds(adPods) ' render current ad pod
if shouldPlayContent
' *** Insert client app’s resume-playback code here
port = CreateObject("roMessagePort")
contentVideoScreen = CreateObject("roVideoScreen")
contentVideoScreen.setMessagePort(port)
contentVideoScreen.PlayStart = curPos
contentVideoScreen.SetContent(videoclip)
contentVideoScreen.show()
end if
end if
' *** Insert client app’s video event handler code here
if type(msg) = "roVideoScreenEvent"
print "showVideoScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed() then 'ScreenClosed event
print "Closing video screen"
exit while
else if msg.isFullResult() then
print "play back completed"
exit while
else if msg.isPaused() then
print("video Paused")
else if msg.isResumed() then
print("video Resumed")
else if msg.isPartialResult()
print "playback interrupted"
exit while
else if msg.isRequestFailed()
print "request failed - error: "
exit while
else if msg.isPlaybackPosition() then
print("playback position="+str(msg.GetIndex()))
curPos = msg.GetIndex()
end if
end if
end while
After completion of midroll ad, the main video content resumes. But I am not able to see only playbackposition event and able to see all the other events(pause/resume/FullResult/PartialResult). Can some one please specify is there anything I have missed?