"RokuMarkn" wrote:
1. In the audioapp sample, AudioInit creates a MessagePort and stores it in o.port. It calls roAudioPlayer.SetMessagePort using that port, and then later Show_Audio_Screen calls create_springboard which calls roSpringboardScreen.SetMessagePort using the same port. Thus messages for both the roAudioPlayer and the roSpringboardScreen will be sent to the same port.
"squirreltown" wrote:
Ok so i've tried a whole bunch of things that don't work. My question is if the roAudioPlayer doesn't receive isRemoteKeyPressed events, how does sharing the port with some other component that does receive isRemoteKeyPressed events change things - I'm still trying to talk to the roAudioPlayer not the screen I'm on.
"squirreltown" wrote:
I've added an info paragraph (from the simpleinfo example) which has the ability to have a button on it. Would it be easier to have a "stop Audio" button there? The sharing port thing isn't going to happen, its just beyond me.
"RokuChris" wrote:
Generally, best practice is to use a roSpringboardScreen as an audio UI. You could certainly add one or more on-screen buttons there to control playback. Take a look at Live365, Amazon Cloud Player, Pandora as examples.
Function DisplayInfomenu(infotype)
infomenu = createobject("romessagedialog")
infomenu.setmessageport(createobject("romessageport"))
infomenu.enableoverlay(true)
if (infotype = 0)
infomenu.setTitle("xxx")
infomenu.settext("xxx")
'infomenu.addbutton(1,"Play Music")
infomenu.addbutton(4,"done")
'infomenu.setfocusedmenuitem(1) ' 2nd button
elseif (infotype = 1)
infomenu.setTitle("xxx")
infomenu.settext("xxx")
'infomenu.addbutton(1,"Play Music")
infomenu.addbutton(4,"done")
'infomenu.setfocusedmenuitem(1) ' 2nd button
elseif (infotype = 2)
infomenu.setTitle("xxx")
infomenu.settext("xxx")
infomenu.addbutton(3,"Show Music Controls")
infomenu.addbutton(4,"done")
'infomenu.setfocusedmenuitem(1) ' 2nd button
elseif (infotype = 3)
infomenu.setTitle("xxx")
infomenu.settext("xxx")
'infomenu.addbutton(1,"Play Music")
infomenu.addbutton(4,"done")
'infomenu.setfocusedmenuitem(1) ' 2nd button
else
infomenu.setTitle("xxx")
infomenu.settext("xxx")
'infomenu.addbutton(1,"Play Music")
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
port = CreateObject("roMessagePort")
audio = CreateObject("roAudioPlayer")
audio.SetMessagePort(port)
item = CreateObject("roAssociativeArray")
item.Url = "http://www.xxx.com/roku/songs/Nightfall.mp3"
item.Artist = "xxx"
item.Title = "NightFall"
item.Album = "Alls Well That Ends Well"
item.HDPosterUrl = "pkg:/images/albumcover_hd.png"
item.SDPosterUrl = "pkg:/images/albumcover_sd.png"
item.StreamFormat = "mp3"
audio.AddContent(item)
audio.SetLoop(0)
audio.SetNext(0)
scr = CreateObject("roSpringboardScreen")
scr.SetDescriptionStyle("audio")
ContentType = "audio"
scr.SetMessagePort(port)
scr.SetStaticRatingEnabled(false)
scr.SetContent(item)
scr.AddButton(1, "Play Music")
scr.AddButton(5, "Done")
scr.SetPosterStyle("rounded-square-generic")
scr.Show()
while true
msg = wait(0, port)
if type (msg) = "roSpringboardScreenEvent"
if msg.isScreenClosed()
exit while
else if msg.isButtonPressed()
button = msg.GetIndex ()
if button = 1 ' Play Button
audio.Play()
scr.ClearButtons()
scr.AddButton(2, "Pause")
scr.AddButton(4, "Stop")
scr.AddButton(5, "Done")
else if button = 2 ' Pause Button
audio.Pause()
scr.ClearButtons()
scr.AddButton(3, "Resume")
scr.AddButton(4, "Stop")
scr.AddButton(5, "Done")
else if button = 3 ' Resume Button
audio.Resume()
scr.ClearButtons()
scr.AddButton(2, "Pause")
scr.AddButton(4, "Stop")
scr.AddButton(5, "Done")
else if button = 4 ' Stop Button
audio.Stop()
scr.ClearButtons()
scr.AddButton(1, "Play Music")
scr.AddButton(5, "Done")
else if button = 5 ' Done Button
scr.Close()
endif
end if
else if type (msg) = "roAudioPlayerEvent"
' Do nothing
end if
end while
endif
end if
endif
end while
end function
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
Thanks for your patience — we’re excited to share what’s next!