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

roLIstScreen is not working properly

I am developing a channel which has a roListScreen which is called recursively.
I am creating listscreen using the same function again and again.
Whenever next ListScreen is created in stack and I return back to the previous screen ,
reference of previous screen is lost and event does not work here.
Please provide me solution so that I can create multiple roListScreen with same function and can handle remote event for each screen.
I dont want to make a different function for each listScreen.

Sample code is given below:

Function appMenuScreen(id as String, title as String) As Dynamic

print "showListScreen Started"
screen = CreateObject("roListScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetHeader(Title)
menuJson = getJson(m.menuURL + id)
screen.SetContent(menuJson.categories)
screen.show()


while (true)
msg = wait(0, port)
if (type(msg) = "roListScreenEvent")
if (msg.isListItemFocused())
print "Title name = ";menuJson.categories[msg.GetIndex()].Title
print "Title id isListItemFocused = ";menuJson.categories[msg.GetIndex()].id
else if (msg.isListItemSelected())
if menuJson.categories[msg.GetIndex()].type = "category"
appMenuScreen(menuJson.categories[msg.GetIndex()].id, menuJson.categories[msg.GetIndex()].Title)
else
displayVideo(menuJson.categories[msg.GetIndex()].id)
endif
'ShowMessageDialog()
endif
endif

end while
End Function
0 Kudos
2 REPLIES 2
joelfire
Visitor

Re: roLIstScreen is not working properly

arifkhan check your facebook i am your friend David.
I hope this brochure will be helpful to you.
'Library "v30/bslDefender.brs"
Function Main() as void
di = CreateObject("roDeviceInfo")
print di.GetModel()
print di.GetVersion()
print di.GetDeviceUniqueId()

screen = CreateObject("roListScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
InitTheme()
screen.SetHeader("NEW TV")
screen.SetBreadcrumbText("Menu", "Breakfast")

contentList = InitContentList()
screen.SetContent(contentList)
screen.show()

while (true)
msg = wait(0, port)
if (type(msg) = "roListScreenEvent")
if (msg.isListItemFocused())
screen.SetBreadcrumbText("Menu", contentList[msg.GetIndex()].Title)
endif
if (msg.isListItemSelected())
'screen.SetBreadcrumbText("Menu", contentList[msg.GetIndex()].Title)
'if (msg.GetIndex() = 0)
displayVideo("", msg.GetIndex())
'print "Selected Index: " + msg.GetIndex()
'title = "Selected:" '+ msg.GetIndex()
'dialog = CreateObject( "roOneLineDialog" )
'dialog.SetTitle( "Selected" )
'dialog.SetTitle(msg.GetIndex())
'dialog.ShowBusyAnimation()
'dialog.show()
'm = wait(500, dialog)
'Sleep(4000)
'endif
endif
endif
end while
End Function

Function InitTheme() as void
app = CreateObject("roAppManager")

primaryText = "#FFFFFF"
secondaryText = "#707070"
'buttonText = "#C0C0C0"
'buttonHighlight = "#ffffff"
listItemHighlight = "#FFFFFF"
listItemText = "#707070"
brandingGreen = "#37491D"
backgroundColor = "#000000"
theme = {
BackgroundColor: backgroundColor
OverhangSliceHD: "pkg:/images/Overhang_Slice_HD.png"
OverhangSliceSD: "pkg:/images/Overhang_Slice_HD.png"
OverhangLogoHD: "pkg:/images/channel_diner_logo.png"
OverhangLogoSD: "pkg:/images/channel_diner_logo.png"
OverhangOffsetSD_X: "25"
OverhangOffsetSD_Y: "15"
OverhangOffsetHD_X: "25"
OverhangOffsetHD_Y: "15"
BreadcrumbTextLeft: brandingGreen
BreadcrumbTextRight: "#E1DFE0"
BreadcrumbDelimiter: brandingGreen

ListItemText: listItemText
ListItemHighlightText: listItemHighlight
ListScreenDescriptionText: listItemText
ListItemHighlightHD: "pkg:/images/select_bkgnd.png"
ListItemHighlightSD: "pkg:/images/select_bkgnd.png"
CounterTextLeft: brandingGreen
CounterSeparator: brandingGreen
GridScreenBackgroundColor: backgroundColor
GridScreenListNameColor: brandingGreen
GridScreenDescriptionTitleColor: brandingGreen
GridScreenLogoHD: "pkg://images/channel_diner_logo.png"
GridScreenLogoSD: "pkg://images/channel_diner_logo.png"
GridScreenOverhangHeightHD: "138"
GridScreenOverhangHeightSD: "138"
GridScreenOverhangSliceHD: "pkg:/images/Overhang_Slice_HD.png"
GridScreenOverhangSliceSD: "pkg:/images/Overhang_Slice_HD.png"
GridScreenLogoOffsetHD_X: "25"
GridScreenLogoOffsetHD_Y: "15"
GridScreenLogoOffsetSD_X: "25"
GridScreenLogoOffsetSD_Y: "15"
}
app.SetTheme( theme )
End Function

Function InitContentList() as object
contentList = [
{
Title: "Channel1",
ID: "1",
SDSmallIconUrl: "pkg:/images/",
HDSmallIconUrl: "pkg:/images/",
HDBackgroundImageUrl: "pkg:/images/telea.png",
SDBackgroundImageUrl: "",
ShortDescriptionLine1: "Channel1",
ShortDescriptionLine2: "Channel Description Text"
},
{
Title: "Channel2",
ID: "2",
SDSmallIconUrl: "pkg:/images/gb_small.jpg",
HDSmallIconUrl: "pkg:/images/gb_small.jpg",
HDBackgroundImageUrl: "pkg:/images/gb1.jpg",
SDBackgroundImageUrl: "pkg:/images/gb1.jpg",
ShortDescriptionLine1: "Channel2",
ShortDescriptionLine2: "Channel Description Text"
},
{
Title: "Channel3",
ID: "3",
SDSmallIconUrl: "pkg:/images/SATV_small.jpg",
HDSmallIconUrl: "pkg:/images/SATV_small.jpg",
HDBackgroundImageUrl: "pkg:/images/SATV.jpg",
SDBackgroundImageUrl: "pkg:/images/SATV.jpg",
ShortDescriptionLine1: "Channel3",
ShortDescriptionLine2: "Channel Description Text"
},
{
Title: "Channel4",
ID: "4",
SDSmallIconUrl: "pkg:/images/jamuna_small.jpg",
HDSmallIconUrl: "pkg:/images/jamuna_small.jpg",
HDBackgroundImageUrl: "pkg:/images/jamuna4.jpg",
SDBackgroundImageUrl: "pkg:/images/jamuna4.jpg",
ShortDescriptionLine1: "Channel4",
ShortDescriptionLine2: "Channel Description Text"
}
{
Title: "Channel5",
ID: "5",
SDSmallIconUrl: "pkg:/images/ind_small.jpg",
HDSmallIconUrl: "pkg:/images/ind_small.jpg",
HDBackgroundImageUrl: "pkg:/images/inde.jpg",
SDBackgroundImageUrl: "pkg:/images/inde.jpg",
ShortDescriptionLine1: "Channel5",
ShortDescriptionLine2: "Channel Description Text"
}
{
Title: "Channel6",
ID: "6",
SDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDBackgroundImageUrl: "pkg:/images/channeli.jpg",
SDBackgroundImageUrl: "pkg:/images/channeli.jpg",
ShortDescriptionLine1: "Channel6",
ShortDescriptionLine2: "Channel Description Text"
}
{
Title: "Channel7",
ID: "7",
SDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDBackgroundImageUrl: "pkg:/images/channeli.jpg",
SDBackgroundImageUrl: "pkg:/images/channeli.jpg",
ShortDescriptionLine1: "Channel7",
ShortDescriptionLine2: "Channel Description Text"
}
{
Title: "Channel8",
ID: "8",
SDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDBackgroundImageUrl: "http://www.underconsideration.com/brandnew/archives/telemundo_logo_detail.jpg",
SDBackgroundImageUrl: "http://www.underconsideration.com/brandnew/archives/telemundo_logo_detail.jpg",
ShortDescriptionLine1: "Channel8",
ShortDescriptionLine2: "Channel Description Text"
}
{
Title: "Channel9",
ID: "9",
SDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDSmallIconUrl: "pkg:/images/channel_ise.jpg",
HDBackgroundImageUrl: "pkg:/images/channeli.jpg",
SDBackgroundImageUrl: "pkg:/images/channeli.jpg",
ShortDescriptionLine1: "Channel9",
ShortDescriptionLine2: "Channel Description Text"
}
]
return contentList
End Function

Function displayVideo(args As Dynamic, tv As integer)
print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)

'bitrates = [0] ' 0 = no dots, adaptive bitrate
'bitrates = [348] ' <500 Kbps = 1 dot
'bitrates = [664] ' <800 Kbps = 2 dots
'bitrates = [996] ' <1.1Mbps = 3 dots
'bitrates = [2048] ' >=1.1Mbps = 4 dots
bitrates = [0]

'Swap the commented values below to play different video clips...
urls = ["http://video.ted.com/talks/podcast/CraigVenter_2008_480.mp4"]
qualities = ["HD"]
StreamFormat = "mp4"
title = "Craig Venter Synthetic Life"
srt = "file://pkg:/source/craigventer.srt"

'urls = ["http://video.ted.com/talks/podcast/DanGilbert_2004_480.mp4"]
'qualities = ["HD"]
'StreamFormat = "mp4"
'title = "Dan Gilbert asks, Why are we happy?"

' Apple's HLS test stream
'urls = ["http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]
'urls = ["http://mobs.jagobd.com:1935/c2VydmVyX3RpbWU9My8xLzIwMTQgMjo1MTo1NCBBTSZoYXNoX3ZhbHVlPXFmcG5iZ1g4S1VMeEFBMGNUMTV5VlE9PSZ2YWxpZG1pbnV0ZXVzPTI/en1-sat.stream/playlist.m3u8?key=c2VydmVyX3RpbWU9My8yNi8yMDE1IDM6Mjg6MTggQU0maGFzaF92YWx1ZT1aaGtzVDhsMld0a0Ria2liYWNURUtnPT0mdmFsaWRtaW51dGVzPTIwMA=="]

If tv = 0
urls = ["http://YOURSTREAMURL/CHANNEL1.m3u8"]
'urls = ["http://mobs.jagobd.com:1935/c2VydmVyX3RpbWU9My8xLzIwMTQgMjo1MTo1NCBBTSZoYXNoX3ZhbHVlPXFmcG5iZ1g4S1VMeEFBMGNUMTV5VlE9PSZ2YWxpZG1pbnV0ZXVzPTI/mob0000ntv0000.stream/playlist.m3u8?key=c2VydmVyX3RpbWU9My8yOC8yMDE1IDY6NDY6MzAgQU0maGFzaF92YWx1ZT1wMmNTSGJMaHVBUmJ5UWI3cWp5L0lnPT0mdmFsaWRtaW51dGVzPTIwMA=="]
Else If tv = 1
urls = ["http://YOURSTREAMURL/CHANNEL2.m3u8"]
Else If tv = 2
urls = ["http://YOURSTREAMURL/CHANNEL3.m3u8"]
Else If tv = 3
'urls = ["http://mobs.jagobd.com:1935/c2VydmVyX3RpbWU9My8xLzIwMTQgMjo1MTo1NCBBTSZoYXNoX3ZhbHVlPXFmcG5iZ1g4S1VMeEFBMGNUMTV5VlE9PSZ2YWxpZG1pbnV0ZXVzPTI/ekattor001122332445574455666-25.stream/playlist.m3u8?key=c2VydmVyX3RpbWU9My8yOC8yMDE1IDc6NDk6NDIgQU0maGFzaF92YWx1ZT1vVDhPakFNTXVHQXZNZHpHYkZ1bzRnPT0mdmFsaWRtaW51dGVzPTIwMA=="]
urls = ["http://YOURSTREAMURL/CHANNEL4.m3u8"]
Else If tv = 4
urls = ["http://YOURSTREAMURL/CHANNEL5.m3u8"]
Else If tv = 5
urls = ["http://YOURSTREAMURL/CHANNEL5.m3u8"]
Else If tv = 6
urls = ["http://YOURSTREAMURL/CHANNEL6.m3u8"]
Else If tv = 7
urls = ["http://YOURSTREAMURL/CHANNEL7.m3u8"]
Else If tv = 8
urls = ["http://YOURSTREAMURL/CHANNEL8.m3u8"]

EndIf

qualities = ["SD"]
streamformat = "hls"
title = "Streaming Live Channel"

' Big Buck Bunny test stream from Wowza
'urls = ["http://ec2-174-129-153-104.compute-1.amazonaws.com:1935/vod/smil:BigBuckBunny.smil/playlist.m3u8"]
'qualities = ["SD"]
'streamformat = "hls"
'title = "Big Buck Bunny"

if type(args) = "roAssociativeArray"
if type(args.url) = "roString" and args.url <> "" then
urls[0] = args.url
end if
if type(args.StreamFormat) = "roString" and args.StreamFormat <> "" then
StreamFormat = args.StreamFormat
end if
if type(args.title) = "roString" and args.title <> "" then
title = args.title
else
title = ""
end if
if type(args.srt) = "roString" and args.srt <> "" then
srt = args.StreamFormat
else
srt = ""
end if
end if

videoclip = CreateObject("roAssociativeArray")
videoclip.StreamBitrates = bitrates
videoclip.StreamUrls = urls
videoclip.StreamQualities = qualities
videoclip.StreamFormat = StreamFormat
videoclip.Title = title
videoclip.Live = True
'print "srt = ";srt
'if srt <> invalid and srt <> "" then
' videoclip.SubtitleUrl = srt
'end if

video.SetContent(videoclip)
video.show()

lastSavedPos = 0
statusInterval = 10 'position must change by more than this number of seconds before saving

while true
msg = wait(0, video.GetMessagePort())
if type(msg) = "roVideoScreenEvent"
if msg.isScreenClosed() then 'ScreenClosed event
print "Closing video screen"
exit while
else if msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
if nowpos > 10000

end if
if nowpos > 0
if abs(nowpos - lastSavedPos) > statusInterval
lastSavedPos = nowpos
end if
end if
else if msg.isRequestFailed()
print "Index: "; msg.GetIndex(); " play failed: "; msg.GetMessage()
obj = msg.GetInfo()
for each key in obj
print " " key "=" obj[key]
end for
else if msg.isStreamSegmentInfo()
print "Stream Segment Info"
print "Index: "; msg.GetIndex(); " Message: "; msg.GetMessage() '"BW: "; obj.StreamBandwidth;
obj = msg.GetInfo()
for each key in obj
print " " key "=" obj[key]
end for
else if msg.isStreamStarted()
print "Stream Started"
print "Index: "; msg.GetIndex()'; "Message: "; msg.GetMessage(); "BW: "; obj.StreamBitrate;
obj = msg.GetInfo()
for each key in obj
print " " key "=" obj[key]
end for
else if msg.isStatusMessage()
print "Status Message"
print " msg: "; msg.GetMessage()
else if msg.isTimedMetaData()
print "TimedMeta Data"
print " msg: "; msg.GetMessage()
obj = msg.GetInfo()
for each key in obj
print " " key "=" obj[key]
end for
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
end if
end while
End Function


sharing costs nothing.....................
0 Kudos
djp
Visitor

Re: roLIstScreen is not working properly

have you figured this out? I am having the same issue..
0 Kudos