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: 
Blackhawk
Roku Guru

The loading screen keeps freezing

I keep getting this error
Current Function:
032:
033:
034:      'Returns available ad pod(s) scheduled for rendering or invalid, if none are available.
035:      adPods = RAF.getAds()
036:      playContent = RAF.showAds(adPods) 'show preroll ad pod (if any)
037:
038:      curPos = 0
039:      if playContent
040:*         videoScreen = SetContent(episode)
041:      end if
042:
043:      closingContentScreen = false
044:      contentDone = false
Function Call Operator ( ) attempted on non-function. (runtime error &he0) in pkg:/source/FullRAFIntegration.brs(40)
040:         videoScreen = SetContent(episode)

On this code

Sub PlayContentWithFullRAFIntegration(episode as Object)
'Main facade creation.
canvas = CreateObject("roImageCanvas")
canvas.SetLayer(1, {color: "#000000"})
canvas.SetLayer(2, {text: "Loading..."})
canvas.Show()
 
RAF = Roku_Ads() 'RAF initialize
print "Roku_Ads library version: " + RAF.getLibVersion()
 
RAF.setDebugOutput(true) 'for debug pupropse
 
'RAF content params
RAF.setContentId(episode.contentId)
RAF.SetContentGenre(episode.contentGenre)

'Indicates whether the default Roku backfill ad service URL
'should be used in case the client-configured URL fails (2 retries)
'to return any renderable ads.
RAF.setAdPrefs(true, 2)

 
'Returns available ad pod(s) scheduled for rendering or invalid, if none are available.
adPods = RAF.getAds()
playContent = RAF.showAds(adPods) 'show preroll ad pod (if any)
 
curPos = 0
if playContent
videoScreen = SetContent(episode)
end if
 
closingContentScreen = false
contentDone = false
while playContent
videoMsg = wait(0, videoScreen.GetMessagePort())
if type(videoMsg) = "roVideoScreenEvent"
if videoMsg.isStreamStarted()
canvas.ClearLayer(2)
end if
if videoMsg.isPlaybackPosition()
'cache current playback position for resume after midroll ads
curPos = videoMsg.GetIndex()
end if
 
if not closingContentScreen 'don't check for any more ads while waiting for screen close
if videoMsg.isScreenClosed() 'roVideoScreen sends this message last for all exit conditions
playContent = false
else if videoMsg.isFullResult()
contentDone = true 'don't want to resume playback after postroll ads
end if
 
'check for midroll/postroll ad pods
adPods = RAF.getAds(videoMsg)
if adPods <> invalid and adPods.Count() > 0
'must completely close content screen before showing ads
'for some Roku platforms (e.g., RokuTV), calling Close() will not synchronously
'close the media player and may prevent a new media player from being created
'until the screen is fully closed (app has received the isScreenClosed() event)
videoScreen.Close()
closingContentScreen = true
end if
else if videoMsg.isScreenClosed()
closingContentScreen = false 'now safe to render ads
end if 'closingContentScreen
 
if not closingContentScreen and adPods <> invalid and adPods.Count() > 0
'now safe to render midroll/postroll ads
playContent = RAF.showAds(adPods)
playContent = playContent and not contentDone
if playContent
'resume video playback after midroll ads
episode.PlayStart = curPos
videoScreen = SetContent(episode)
end if
end if '!closingContentScreen
end if 'roVideoScreenEvent
end while
if type(videoScreen) = "roVideoScreen" then videoScreen.Close()
End Sub



I keep checking the code and I'm not sure whats going on
0 Kudos
3 REPLIES 3
joetesta
Roku Guru

Re: The loading screen keeps freezing

setcontent is not a global function you can use like that.  I assume you're trying to do something like what's shown here:

player = CreateObject( "roVideoScreen" ) 
player.setMessagePort( port )
player.setContent( content )

https://sdkdocs.roku.com/display/sdkdoc/Fast+Video+Start
aspiring
0 Kudos
Blackhawk
Roku Guru

Re: The loading screen keeps freezing

I tried setting it up like this
Function showVideoScreen(episode As Object)
 
if type(episode) <> "roAssociativeArray" then
print "invalid data passed to showVideoScreen"
return -1
endif
 
port = CreateObject("roMessagePort")
player = CreateObject( "roVideoScreen" )
player.setMessagePort( port )
player.setContent(episode)
player.Prebuffer()
 
 
 

player.SetPositionNotificationPeriod(30)
 

 
player.Show()
 

 

PlayContentWithFullRAFIntegration(episode)
 
 
 
 
'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)
 
while true
msg = wait(0, port)
 
if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
else
print "Unexpected event type: "; msg.GetType()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while
 
End Function



Yet i get the same error
0 Kudos
joetesta
Roku Guru

Re: The loading screen keeps freezing

"Blackhawk" wrote:
I tried setting it up like this
Function showVideoScreen(episode As Object)
 
if type(episode) <> "roAssociativeArray" then
print "invalid data passed to showVideoScreen"
return -1
endif
 
port = CreateObject("roMessagePort")
player = CreateObject( "roVideoScreen" )
player.setMessagePort( port )
player.setContent(episode)
player.Prebuffer()
 
 
 

player.SetPositionNotificationPeriod(30)
 

 
player.Show()
 

 

PlayContentWithFullRAFIntegration(episode)
 
 
 
 
'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)
 
while true
msg = wait(0, port)
 
if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
else
print "Unexpected event type: "; msg.GetType()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while
 
End Function



Yet i get the same error

If you got the same error then you did not remove the bogus line "videoScreen = SetContent(episode)"
aspiring
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.