Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
rikkrokker
Level 7

Launching an audio player from springboard trouble...

HELP!! Racking my brain and have tried numerous methods to do this:

I have a multilevel app that has a posterscreen with 1 live video feed (ustream fed with a spring board, works great) and 7 audio feeds.
With the original build, I had the audio streams launch directly from main.brs like this:

---------------------------------------
sub main()

app = CreateObject("roAppManager")
theme = CreateObject("roAssociativeArray")
theme.BackgroundColor = "#141313"
theme.OverhangOffsetSD_X = "50"
theme.OverhangOffsetSD_Y = "120"
theme.OverhangSliceSD = "pkg:/images/crn_card1_sd.png"
theme.OverhangPrimaryLogoOffsetSD_Y = "20"
theme.OverhangPrimaryLogoSD = "pkg:/images/logo_sd_sm.png"
theme.OverhangOffsetHD_X = "20"
theme.OverhangOffsetHD_Y = "0"
theme.OverhangSliceHD = "pkg:/images/crn_card1_hd.png"
theme.OverhangPrimaryLogoHD = "pkg:/images/logo_HD.png"
'theme.FilterBannerSliceHD = "pkg:/images/filterbannersliceHD1.png"
app.SetTheme(theme)

xfer=createobject("rourltransfer")
xfer.seturl("http://crntalk.com/podcast/roku/app/xml/livestreamlinks.xml")
RawXMLData=xfer.gettostring()
xml=createobject("roXMLElement")
list=createobject("roArray",0,true)

if xml.parse(RawXMLData) then
for each obj in xml.item
currentitem=createobject("roAssociativeArray")
currentitem.shortdescriptionLine1=obj.title.gettext()
currentitem.shortdescriptionLine2=obj.subtitle.gettext()
currentitem.hdposterurl=obj.hdThumbnail.gettext()
currentitem.sdposterurl=obj.sdThumbnail.gettext()
currentitem.contenttype=obj.contentType.gettext()
currentitem.categories=obj.category.gettext()
currentitem.url=obj.media.streamUrl.gettext()
currentitem.streamformat=obj.streamFormat.gettext()
currentitem.title=currentitem.shortdescriptionLine1
list.push(currentitem)
end for
else
print "parse failed"
end if

poster=createobject("roposterscreen")
port=createobject("romessageport")
poster.setliststyle("arced-landscape")
'poster.setlistnames(["Live Streams"])
poster.setbreadcrumbtext("www.crntalk.com","")
poster.setadurl("http://xxxxxxx.com/podcast/roku/app/images/adbanner_hd.png","http://xxxxxxx.com/podcast/roku/app/images/adbanner_sd.png")
poster.setadselectable(true)
poster.setfocustofilterbanner(false)
poster.setcontentlist(list)
poster.setmessageport(port)
poster.show()

audioplayer=createobject("roaudioplayer")
audioplayer.setmessageport(port)
print list

while true
msg=wait(0,port)
if lcase(type(msg))=lcase("roposterscreenevent") then
print "poster screen event"
if msg.isadselected() then
print "Ad Selected"
showParagraphScreen(true)
end if
ndx=msg.getindex(): print msg.getindex()

if msg.getindex() <> 0 then
if msg.islistitemselected() then
audioplayer.stop()
audioplayer.clearcontent()
sleep(500)
audioplayer.addcontent(list[ndx])
audioplayer.play()

end if

else if msg.getindex() = 0 then
if msg.islistitemselected() then
audioplayer.stop()
audioplayer.clearcontent()
showSpringboardScreen(list[ndx])

'exit the app gently so that the screen doesn't flash to black
poster.showMessage("")
sleep(25)

end if
end if
else if type(msg)="roAudioPlayerEvent"
print msg.getmessage()

if msg.isStatusMessage() and msg.GetMessage() = "startup progress" then
busydialog=CreateObject("roOneLineDialog") ' creates a dialog box
busydialog.SetMessagePort(poster.GetmessagePort()) 'sets a message port for the dialog box
busydialog.SetTitle("Your CRN Live Stream will begin momentarily. ") 'displays a line of text for the dialog box title
busydialog.ShowBusyAnimation() ' enables a spinning animation
busydialog.Show() ' makes the dialog box and busy animation display

else if msg.isStatusMessage() and msg.GetMessage() = "start of play" then
busydialog.Close()

else if msg.isStatusMessage() and msg.GetMessage() = "end of playlist" then
busydialog.Close()
busydialog=CreateObject("roOneLineDialog") ' creates a dialog box
busydialog.SetMessagePort(poster.GetmessagePort()) 'sets a message port for the dialog box
busydialog.SetTitle("The Connection Timed Out.") 'displays a line of text for the dialog box title
busydialog.Show() ' makes the dialog box
'timeout = 1 * 10 * 500 '5 second delay
busydialog.Close()
end if
end if
end while
end sub
-----------------------------

This worked fine, As you see here the springboard is launched for the video, the stream URL is embedded in the video springboard. The audioplayer is launched from main.

What I wanted to do was add a springboard for the audio streams as well, and the springboard works as far as the content data on the springboard screens for the audio channels is concerned, but for some reason can't pass the item meta-data from the springboard to my playaudio.brs object:

---------------------------------------------

'*************************************************************
'** playaudio()
'*************************************************************

function playaudio(item as object) as integer
print "Audio Player Selected"
audio=createobject("roaudioplayer")
port=createobject("romessageport")
audio.SetMessagePort (port)
if item <> invalid and type(item) = "roAssociativeArray"
audio.addContent(item)
audio.play()
else print "invalid"
return -1
end if

while true
msg=wait(0,port)
if lcase(type(msg))="roaudioplayerevent" then
print msg.getmessage()

if msg.isStatusMessage() and msg.GetMessage() = "startup progress" then
busydialog=CreateObject("roOneLineDialog") ' creates a dialog box
busydialog.SetMessagePort(poster.GetmessagePort()) 'sets a message port for the dialog box
busydialog.SetTitle("Your CRN Live Stream will begin momentarily. ") 'displays a line of text for the dialog box title
busydialog.ShowBusyAnimation() ' enables a spinning animation
busydialog.Show() ' makes the dialog box and busy animation display

else if msg.isStatusMessage() and msg.GetMessage() = "start of play" then
busydialog.Close()

else if msg.isStatusMessage() and msg.GetMessage() = "end of playlist" then
busydialog.Close()
busydialog=CreateObject("roOneLineDialog") ' creates a dialog box
busydialog.SetMessagePort(poster.GetmessagePort()) 'sets a message port for the dialog box
busydialog.SetTitle("The Connection Timed Out.") 'displays a line of text for the dialog box title
busydialog.Show() ' makes the dialog box
'timeout = 1 * 10 * 500 '5 second delay
busydialog.Close()

else if msg.isRequestSucceeded() then
return -1
else if msg.isrequestfailed() then
print "Failed to aquire stream"
return -2
end if
end if
end while
end function
---------------------------------------------

The reference to playaudio in the audio springboard is as follows:

----------------------------------

Function showAudioSpringboardScreen(item as object) As Boolean
aud = CreateObject("roSpringboardScreen")
port = CreateObject("roMessagePort")
print "showAudioSpringboardScreen"

aud.SetMessagePort(port)
aud.AllowUpdates(false)
aud.SetBreadcrumbText("Live Audio Stream","")
aud.SetBreadcrumbEnabled(true)
if item <> invalid and type(item) = "roAssociativeArray"
aud.SetContent(item)

endif

aud.SetDescriptionStyle("audio") 'audio, movie, video, generic
' generic+episode=4x3,
aud.ClearButtons()
aud.AddButton(1,"Play")
aud.AddButton(2,"Network Schedule")
aud.AddButton(3,"Go Back")
aud.SetStaticRatingEnabled(false)
aud.AllowUpdates(true)
aud.setadurl("http://xxxxxxx.com/podcast/roku/app/images/adbanner_hd.png","http://xxxxxxx.com/podcast/roku/app/images/adbanner_sd.png")
aud.setAdSelectable(true)
aud.Show()

downKey=3
selectKey=6
while true
msg = wait(0, aud.GetMessagePort())
if type(msg) = "roSpringboardScreenEvent"
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isadselected() then
print "Ad Selected"
showParagraphScreen(true)
'end if
else if msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
if msg.GetIndex() = 1
playAudio("")
else if msg.GetIndex() = 2
showLiveCamSchedScreen(true)
else if msg.GetIndex() = 3
return true
endif
else
print "Unknown event: "; msg.GetType(); " msg: "; msg.GetMessage()
endif
else
print "wrong type.... type=";msg.GetType(); " msg: "; msg.GetMessage()
endif
end while


return true
End Function
---------------------------------

what the heck am I doing wrong?

Erik
0 Kudos
3 Replies
Highlighted
rikkrokker
Level 7

Re: Launching an audio player from springboard trouble...

BTW, the beta channel that works is vanity code 10487 if you're interested....

Erik
0 Kudos
rikkrokker
Level 7

Re: Launching an audio player from springboard trouble...

The output after clicking 'play' on the Audiospringboard displays 'invalid' per the print line if the roassociative array is invalid...

Erik
0 Kudos
Highlighted
RokuMarkn
Level 7

Re: Launching an audio player from springboard trouble...

playaudio is expecting its parameter to be an associative array, but you're passing it a string (an empty string). You can print type(item) in playaudio to verify what you're getting.

--Mark
0 Kudos