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

Re: saving variable.

Added print curr_photo to the block where its initialized and get this back for each slide while the canvas shows the proper title.

gettitle:<bsTypedValue: Function>
http: <Component: roUrlTransfer>
xml: <Component: roXMLElement>
geturl: <bsTypedValue: Function>

also same result adding print cur_photo to the RemoteKey pressed block


thanks
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: saving variable.

 else if msg.isRemoteKeyPressed()
onscreenphoto = msg.GetIndex()
curr_photo = photolist[onscreenphoto]
if msg.GetIndex() = 10
DisplayInfomenu(6, curr_photo)
end if


It seems clear that the problem is in this block onscreenphoto is getting the index from isRemoteKeyPressed not isPlaybackPosition which is what i need. If i take out the onscreenphoto = msg.GetIndex() line it goes back to the Typemismatch error so how to get the isButtonPressed index in the RemoteKey block?
Not clear why onscreenphoto (and curr_photo) needs to be re-defined in this block.

thanks
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: saving variable.

Take out both the assignment to onscreenphoto and curr_photo under isRemoteKeyPressed. Those are set under isPlaybackPosition and should not be changed in isRemoteKeyPressed.

--Mark
0 Kudos
squirreltown
Roku Guru

Re: saving variable.

"RokuMarkn" wrote:
Take out both the assignment to onscreenphoto and curr_photo under isRemoteKeyPressed. Those are set under isPlaybackPosition and should not be changed in isRemoteKeyPressed.

--Mark

Thank you Mark. OK wrong thing to do - However, that takes me back to where i started this morning with this:
Type Mismatch. (runtime error &h18) in ...g:/source/mediarsstoolkit.brs(270)
270: Function DisplayInfomenu(infotype As Object, curr_photo As Object)


The isRemoteKeyPressed block seems to be not recognizing that curr_photo is previously defined ? Or another reason for the Type Mismatch?

thanks
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: saving variable.

I think I introduced this bug because I thought that infotype was an AA. It looks like it's an integer? If so, change the function definition to

Function DisplayInfomenu(infotype As Integer, curr_photo As Object)


--Mark
0 Kudos
squirreltown
Roku Guru

Re: saving variable.

"RokuMarkn" wrote:
I think I introduced this bug because I thought that infotype was an AA. It looks like it's an integer? If so, change the function definition to

Function DisplayInfomenu(infotype As Integer, curr_photo As Object)


--Mark

Sorry to say that wasn't it. BTW I tried changing both and each type to Integer last night (only other type that seemed posible) - Same Type Mismatch Here is the function itself:
Function DisplayInfomenu(infotype As Object, curr_photo As Object)
infomenu = createobject("romessagedialog")
infomenu.setmessageport(createobject("romessageport"))
infomenu.enableoverlay(true)
if (infotype = 6)
infomenu.setTitle(curr_photo.GetTitle())
infomenu.settext( " Assembled Photography Slideshow" + chr(10) + + chr(10) + "Right Arrow to skip forward, Left Arrow to skip backwards, Play/Pause to stop or resume. Up Arrow to return to Home Page." )
infomenu.addbutton(3,"Music")
infomenu.addbutton(4,"Done")
infomenu.setfocusedmenuitem(1) ' 2nd button
else
infomenu.setTitle("TEMP TITLE")
infomenu.settext("TEMP TEXT")
infomenu.addbutton(4,"done")
infomenu.setfocusedmenuitem(1) ' 2nd button
endif
infomenu.show()
while true
msg = wait(0,infomenu.getmessageport())
if msg.isscreenclosed() return 0
if msg.isButtonInfo() return 0 ' Info pressed again, dismiss the info overlay
if msg.isbuttonpressed()
button = msg.getindex()
print "Info Button ";button;" pressed"
if button = 4
return button
endif
if msg.isbuttonpressed()
button = msg.getindex()
print "Info Button ";button;" pressed"
if button = 3
AudioPlay()
return 0
end if
end if
endif
end while

end function

but yes it does seem like infotype is an integer.
thanks

EDIT i tried removing the infotype parameter completely from this function and its references and still got a type mismatch on just curr_photo.
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: saving variable.

The function you quoted in your last post still has both defined as Object. Please try it the way I wrote it, with infotype as Integer and curr_photo as Object.

--Mark
0 Kudos
squirreltown
Roku Guru

Re: saving variable.

"RokuMarkn" wrote:
The function you quoted in your last post still has both defined as Object. Please try it the way I wrote it, with infotype as Integer and curr_photo as Object.

--Mark

Ok sorry if I was confusing, I did try it as you wrote it, I did still get the type mismatch error, and just tried it again and got the error again.
current function:
Function DisplayInfomenu(infotype As Integer, curr_photo As Object)
infomenu = createobject("romessagedialog")
infomenu.setmessageport(createobject("romessageport"))
infomenu.enableoverlay(true)
if (infotype = 6)
infomenu.setTitle(curr_photo.GetTitle())
infomenu.settext( " Assembled Photography Slideshow" + chr(10) + + chr(10) + "Right Arrow to skip forward, Left Arrow to skip backwards, Play/Pause to stop or resume. Up Arrow to return to Home Page." )
infomenu.addbutton(3,"Music")
infomenu.addbutton(4,"Done")
infomenu.setfocusedmenuitem(1) ' 2nd button
else
infomenu.setTitle("TEMP TITLE")
infomenu.settext("TEMP TEXT")
infomenu.addbutton(4,"done")
infomenu.setfocusedmenuitem(1) ' 2nd button
endif
infomenu.show()
while true
msg = wait(0,infomenu.getmessageport())
if msg.isscreenclosed() return 0
if msg.isButtonInfo() return 0 ' Info pressed again, dismiss the info overlay
if msg.isbuttonpressed()
button = msg.getindex()
print "Info Button ";button;" pressed"
if button = 4
return button
endif
if msg.isbuttonpressed()
button = msg.getindex()
print "Info Button ";button;" pressed"
if button = 3
AudioPlay()
return 0
end if
end if
endif
end while

end function


Current error:
Type Mismatch. (runtime error &h18) in ...g:/source/mediarsstoolkit.brs(268)

268: Function DisplayInfomenu(infotype As Integer, curr_photo As Object)
Backtrace:
Function displayinfomenu(infotype As Integer, curr_photo As <uninitialized>) As
file/line: /tmp/plugin/LDCAAAmLxswl...g:/source/mediarsstoolkit.brs(269)
Function displayslideshow(slideshow As , photolist As ) As
file/line: /tmp/plugin/LDCAAAmLxswl...g:/source/mediarsstoolkit.brs(228)
Function displayredzplace() As
file/line: /tmp/plugin/LDCAAAmLxswl...g:/source/mediarsstoolkit.brs(68)
Function uitkdopostermenu(posterdata As , screen As , onselect_callback As ) As Integer
file/line: /tmp/plugin/LDCAAAmLxswl/pkg:/source/uitoolkit.brs(96)
Function main() As
file/line: /tmp/plugin/LDCAAAmLxswl/pkg:/source/main.brs(60)

Local Variables:
infotype &h0002 Integer val:6
curr_photo &h0000 <uninitialized> val:Uninitialized
global &h0020 rotINTERFACE:ifGlobal
m &h0010 bsc:roAssociativeArray, refcnt=4
infomenu &h0000 <uninitialized> val:Uninitialized
msg &h0000 <uninitialized> val:Uninitialized
button &h0000 <uninitialized> val:Uninitialized


Thanks
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: saving variable.

Can you post the calling function?
--Mark
0 Kudos
squirreltown
Roku Guru

Re: saving variable.

"RokuMarkn" wrote:
Can you post the calling function?
--Mark


OK here it is. The call is about 100 lines down, after the canvas.

Sub DisplaySlideShow(slideshow, photolist)

screenFacade = CreateObject("roPosterScreen")
screenFacade.show()
screenFacade.showMessage("Loading...")



print "in DisplaySlideShow"
'using SetContentList()

contentArray = CreateObject("roArray", photolist.Count(), true)
for each photo in photolist
print "---- new DisplaySlideShow photolist loop ----"
url = photo.GetURL()
if url<>invalid then
aa = CreateObject("roAssociativeArray")
aa.Url = url
contentArray.Push(aa)
print "PRELOAD TITLE: ";photo.GetTitle()

end if
next
slideshow.SetContentList(contentArray)


'this is an alternate technique for adding content using AddContent():
'aa = CreateObject("roAssociativeArray")
'for each photo in photolist
'print "---- new DisplaySlideShow photolist loop ----"
'url = photo.GetURL()
'if url<>invalid then
' aa.Url = url
' slideshow.AddContent(aa)
' print "PRELOAD TITLE: ";photo.GetTitle()
'end if
'next


btn_more_from_author = 0
btn_similar = 1
btn_bookmark = 2
btn_hide = 13




screenFacade.close()
waitformsg:
msg = wait(0, m.port)



print "DisplaySlideShow: class of msg: ";type(msg); " type:";msg.gettype()
'for each x in msg:print x;"=";msg[x]:next
if msg <> invalid then 'invalid is timed-out
if type(msg) = "roSlideShowEvent" then
if msg.isScreenClosed() then
return
else if msg.isButtonPressed() then
print "Menu button pressed: " + Stri(msg.GetIndex())
'example button usage during pause:
'if msg.GetIndex() = btn_hide slideshow.ClearButtons()



else if msg.isPlaybackPosition() then
onscreenphoto = msg.GetIndex()
curr_photo = photolist[onscreenphoto]
print "slideshow display: " + Stri(msg.GetIndex())




canvas = CreateObject( "roImageCanvas" )
fontReg = CreateObject("roFontRegistry")
fontReg.Register("pkg:/fonts/caps.otf")
font = fontReg.Get("caps",28,50,true)

bgRect = {
Color: "#00000000",
TargetRect: { x: 55, y: 10, w: 280, h: 50 }
}
text = {
Text: curr_photo.GetTitle(),
TextAttrs:{Color:"#960404", Font:font,
HAlign:"Left", VAlign:"VCenter", Direction:"LeftToRight"}

TargetRect: bgRect.TargetRect
}
canvas.SetLayer( 0, [ bgRect, text ] )

canvas.Show()
Sleep( 2500 )
canvas.Close()



else if msg.isRemoteKeyPressed()
if msg.GetIndex() = 10
DisplayInfomenu(6, curr_photo)
end if
endif

else if msg.isRemoteKeyPressed() then
print "Button pressed: " + Stri(msg.GetIndex())
else if msg.isRequestSucceeded() then
print "preload succeeded: " + Stri(msg.GetIndex())
elseif msg.isRequestFailed() then
print "preload failed: " + Stri(msg.GetIndex())
elseif msg.isRequestInterrupted() then
print "preload interrupted" + Stri(msg.GetIndex())
elseif msg.isPaused() then
print "paused"

'example button usage during pause:
'buttons will only be shown in when the slideshow is paused
'slideshow.AddButton(btn_more_from_author, "more photos from this author")
'slideshow.AddButton(btn_similar, "similar")
'slideshow.AddButton(btn_bookmark, curr_photo.GetTitle())
'slideshow.AddButton(btn_hide, "hide buttons")
elseif msg.isResumed() then
print "resumed"
'example button usage during pause:
'slideshow.ClearButtons()
end if
end if


goto waitformsg

DisplayInfomenu(infotype, curr_photo)



End Sub
Kinetics Screensavers
0 Kudos