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: 
lbell
Visitor

Message ports?

Can someone tell me what's wrong? I'm getting syntax errors but can't find them.
The errors seem to be around where I set the message ports, I set both the audioPlay and Canvas to the same port should that affect anything?

Function showAudioCanvas(showList As Object, showIndex As Object, isPlayAll As Boolean) As Integer

dinfo = CreateObject("roDeviceInfo")
dsize = dinfo.GetDisplaySize()
dtype = dinfo.GetDisplayType()
width = dsize.w
height = dsize.h

if dtype = "HDTV" then
iurl = "http://www.map2life.com/roku/images/Splash/HD/SplashHDResized.jpg"
if not(width = 1280) or not(height = 720) then
print "WARNING: unusual screen dimensions detected. the splash screen may not display properly."
endif
else
iurl = "http://www.map2life.com/roku/images/Splash/SD/SplashSDResized.jpg"
if not(width = 720) or not(height = 480) then
print "WARNING: unusual screen dimensions detected. the splash screen may not display properly."
endif
endif

image = {
Color:"#000000",
CompositionMode:"Source",
Url:iurl,
TargetRect:{x:0,y:0}
}
 


'set pre audioplayer data
audioPlayer = CreateObject("roAudioPlayer")
port = CreateObject("roMessagePort")
'audioport = CreateObject("roMessagePort")
'set audioplayer message port to the same port as springboardscreen
audioPlayer.SetMessagePort(port)

if isPlayAll then
audioPlayer.SetContentList(showList)
else
audioplayer.addcontent(showList[showIndex])
endif

audioplayer.setloop(false)

   canvas = CreateObject("roImageCanvas")
   'port = CreateObject("roMessagePort")
   canvas.SetMessagePort(port)
   'Set opaque background
   'canvas.SetLayer(0, {Color:"#FF000000", CompositionMode:"Source"})
   canvas.SetRequireAllImagesToDraw(true)
   canvas.SetLayer(1, image)
audioPlayer.Play()
   canvas.Show()
   while(true)
       msg = wait(0,port)
       if type(msg) = "roImageCanvasEvent" then
           if (msg.isRemoteKeyPressed()) then
               index = msg.GetIndex()
               print "Key Pressed - " ; msg.GetIndex()
               if (i = 2) then
audioPlayer.Stop()
                   ' Up - Close the screen.
                   canvas.close()
               else if ( index = 0) then
audioPlayer.Stop()
'back to close
canvas.close()
endif
           else if (msg.isScreenClosed()) then
audioPlayer.Stop()
               print "Closed"
               return
           end if
else if type(msg) = "roAudioPlayerEvent"
if msg.isRequestFailed() then
Error = msg.GetMessage()
ShowDialog1Button("Connection Failed", Error, "Ok")
else if msg.isFullResult() then
return -1
end if
else if type(msg) = "roUniversalControlEvent" then
if msg.GetInt() = 13 then
if audioPlayer.isPaused() then
audioPlayer.Play()
else
audioPlayer.Pause()
endif
endif
       end if
   end while
End Function
0 Kudos
2 REPLIES 2
RokuMarkn
Visitor

Re: Message ports?

It would help if you posted the error message you're getting. The only problem I immediately see is you have one return statement without a value.

--Mark
0 Kudos
lbell
Visitor

Re: Message ports?

*** ERROR compiling /pkg:/source/Audiospringboardscreen.brs:
Syntax Error. (compile error &h02) in pkg:/source/Audiospringboardscreen.brs(129
)
Syntax Error. (compile error &h02) in pkg:/source/Audiospringboardscreen.brs(147
)
Syntax Error. (compile error &h02) in pkg:/source/Audiospringboardscreen.brs(148
)
Syntax Error. (compile error &h02) in pkg:/source/Audiospringboardscreen.brs(149
)
Syntax Error. (compile error &h02) in pkg:/source/Audiospringboardscreen.brs(150
)

Line 129 is the line immediately after the closing brace "}" for image.
I thought it might be confusing the TargetRect closing brace "}" with the image brace but the exact same code runs just fine in a different function so it made me really confused.
0 Kudos