"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.
Thank you Chris. I have added a springboard for the audio, and made the buttons work as I'd like.
Now I added the audio springboard code into the DisplayInfomenu(infotype) function so the springboard gets called by a button on the info page. I see no errors in the debugger. All seems fine until you go back to the slideshow where the OK and * buttons dont work anymore. Left Right and Up still do. So you can start the music, go back to the slideshow but OK wont trigger it. If you just go to the info page and out -no problem. If you go info-then audio springboard and DONT start the audio, you get the problem so its loading the springboard which seems cause the issue. I did try to make the audio springboard a function and call it from a button on the info page but in addition to the above problems it stops the audio when you go back to the slideshow so thats no good.
hope someone can see or recognize this problem
thanks
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
Kinetics Screensavers