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: 

Help with AudioApp

Hi All,

I have modified AudioApp to play three different MP3 streams from the internet. Now I want to add a new item to the poster to show some text (as in the paragraph example). Yet I don't understand how to accomplish this. I could post some code, but it will probably be useless. :?

How can I accomplish this?

Thanks,

Manuel.-
0 Kudos
7 REPLIES 7

Re: Help with AudioApp

Ok, some more info. I've managed to get my aboutUs.brs called from the poster screen. But I get errors in the debugger.

Here is the code for aboutUs.brs:
Function preShowParagraphScreen(breadA=invalid, breadB=invalid) As Object
print "In preShowParagraphScreen"
port=CreateObject("roMessagePort")
screen = CreateObject("roParagraphScreen")
screen.SetMessagePort(port)
return screen
End Function

Function ShowParagraphScreen() As Void
print "In ShowParagraphScreen"
port = CreateObject("roMessagePort")
screen = CreateObject("roParagraphScreen")
screen.SetMessagePort(port)
screen.SetTitle("[Screen Title]")
screen.AddHeaderText("[Header Text]")
screen.AddParagraph("[Paragraph text 1 - Text in the paragraph screen is justified to the right and left edges]")
screen.AddParagraph("[Paragraph text 2 - Multiple paragraphs may be added to the screen by simply making additional calls]")
screen.AddButton(1, "[button text 1]")
screen.AddButton(2, "[button text 2]")
screen.Show()
while true
msg = wait(0, screen.GetMessagePort())
if type(msg) = " roParagraphScreenEvent"
exit while
endif
end while
End Function

Sub DoAboutUs(from as string)
print "In AboutUs.brs!"
screen=preShowParagraphScreen("Paragraph", "")
if screen=invalid then
print "unexpected error in preShowHomeScreen"
return
end if
ShowParagraphScreen(screen)
End Sub


And this is the error in the debugger when I select the poster that calls aboutUs.brs:
list selected:  3
In AboutUs.brs!
In preShowParagraphScreen
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Current Function:
029: Sub DoAboutUs(from as string)
030: print "In AboutUs.brs!"
031: screen=preShowParagraphScreen("Paragraph", "")
032: if screen=invalid then
033: print "unexpected error in preShowHomeScreen"
034: return
035: end if
036: ShowParagraphScreen(screen)
037: End Sub
/tmp/plugin/HKAAAAVJD8RP/pkg:/source/AboutUs.brs(36): runtime error f1: Wrong number of function parameters.

036: ShowParagraphScreen(screen)

Backtrace:
Function doaboutus(from As String) As Void
Function main() As Void

Local Variables:
from &h44 String val:Categories
global &h07 rotINTERFACE:ifGlobal
m &h06 bsc:roAssociativeArray, refcnt=3
screen &h16 bsc:roParagraphScreen, refcnt=1
BrightScript Debugger>


Any ideas?

Thanks,

Manuel.-
0 Kudos
RokuKevin
Visitor

Re: Help with AudioApp

The debugger is your friend... It will tell you what's wrong with your syntax:

In this case:

037: End Sub
/tmp/plugin/HKAAAAVJD8RP/pkg:/source/AboutUs.brs(36): runtime error f1: Wrong number of function parameters.

036: ShowParagraphScreen(screen)

Tells you that the ShowParagraphScreen() definition does not match the call. You called it with one argument and your definition has none.

--Kevin
0 Kudos

Re: Help with AudioApp

Thanks Kevin,

I had figured that one out! I also placed a close button on the About page in order to close it.

Now on to my next task!

Right now, with the AudioApp SDK example, the audio stops playing immediately after returning to the poster screen. Is it possible to keep the audio running and only stop it when entering a different stream?

Thanks,

Manuel.-
0 Kudos
RokuKevin
Visitor

Re: Help with AudioApp

It is possible to keep the audio running and display different screens. You need to share the port for the audioplayer and the screens and service the events both components could send in your event loop.

Please see the audioapp in the SDK examples for some sample source on how to do that.

--Kevin
0 Kudos

Re: Help with AudioApp

Hi Kevin,

I took a look at the audioapp example, but it isn't much help, as the audio stops when I exit the current screen that is playing it. Could you post some sample code?

Regards,

Manuel.-
0 Kudos
kbenson
Visitor

Re: Help with AudioApp

I haven't looked at the code, but make sure the audioplayer component itself is passed back, or saved globally. If it goes out of scope (you return from the function you defined it in, and have not passed it back or saved it to some other location that won't be cleaned up), it will be cleaned (garbage collected) by the VM and stop playing.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
RokuKevin
Visitor

Re: Help with AudioApp

If you want audio to continue playing while navigating to other screens, you must be sure your audio player does not go out of scope as kbenson points out.

You must also be sure all your event loops handle both audio player events and the screen events for the top level screen. A good code organization might be a global event loop.

--Kevin
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.