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: 

roAudioPlayer not playing audio when used with roScreen

I am not able to play audio in the background when displaying roScreen in front. What I am doing is

1- Show an roScreen with roVideoPlayer. (works fine)
after playback of some videos
2- Show same roScreen with different graphics and roAudioPlayer playing background music for some time (almost 30 seconds). (roScreen displays graphics fine but not audio playback in the background. I am pausing roVideoPlayer before displaying this screen)

In the debug console I get roAudioPlayer events with message "startup progress" but when startup progress reaches to 999 after that neither audio is played nor I get any other roAudioPlayer event. And after that when this screen closes and goes to next screen (before which I call roAudioPlayer.Stop()) I get events "startup progress" with value 1000 and "start of play" with value 0. But at this point audio is not played because I have already called roAudioPlayer.Stop() method.

So, I am not able to understand whether it is an issue of usage of a lot of memory because of many memory hungry components or we cannot use roVideoPlayer and roAudioPlayer objects simultaneously (although roVideoPlayer is paused)???? Because same audio clip works fine when I put its URL in roAudioPlayer example from sdkdocs.roku.com

Here is the code snippet:


audioPlayer = CreateObject("roAudioPlayer")
port = CreateObject("roMessagePort")
audioClip = CreateObject("roAssociativeArray")
audioClip.url = "http://www.theflute.co.uk/media/BachCPE_SonataAmin_1.wma"
audioPlayer.AddContent(audioClip)
audioPlayer.SetLoop(true)
audioPlayer.SetMessagePort(port)
audioPlayer.Play()
showScreen()

in the event loop after 30 seconds
audioPlayer.Stop()
updateScreen()
showScreen()
0 Kudos
5 REPLIES 5
TheEndless
Channel Surfer

Re: roAudioPlayer not playing audio when used with roScreen

I don't think you can use the roVideoPlayer and roAudioPlayer at the same time. You'll need to Stop() the roVideoPlayer, not just pause it.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos

Re: roAudioPlayer not playing audio when used with roScreen

"TheEndless" wrote:
I don't think you can use the roVideoPlayer and roAudioPlayer at the same time. You'll need to Stop() the roVideoPlayer, not just pause it.


Yes, you are right roAudioPlayer cannot be used with roVideoPlayer. But even Stop()ing the roVideoPlayer did not work, I had to set roVideoPlayer object equal to Invalid, then I was able to play sound with roAudioPlayer.
0 Kudos
TheEndless
Channel Surfer

Re: roAudioPlayer not playing audio when used with roScreen

"scorpiontahir02" wrote:
"TheEndless" wrote:
I don't think you can use the roVideoPlayer and roAudioPlayer at the same time. You'll need to Stop() the roVideoPlayer, not just pause it.


Yes, you are right roAudioPlayer cannot be used with roVideoPlayer. But even Stop()ing the roVideoPlayer did not work, I had to set roVideoPlayer object equal to Invalid, then I was able to play sound with roAudioPlayer.

For what it's worth, roVideoPlayer supports audio playback, so you could just reset its content, instead of invalidating it.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos

Re: roAudioPlayer not playing audio when used with roScreen

"TheEndless" wrote:

For what it's worth, roVideoPlayer supports audio playback, so you could just reset its content, instead of invalidating it.


Ok! Thank you very much for your help! but I have already used roAudioPlayer now 🙂 and I think there is not much difference in using both the apporaches but both the players should be used for the purposes they are made for.
0 Kudos
TheEndless
Channel Surfer

Re: roAudioPlayer not playing audio when used with roScreen

"scorpiontahir02" wrote:
"TheEndless" wrote:

For what it's worth, roVideoPlayer supports audio playback, so you could just reset its content, instead of invalidating it.


Ok! Thank you very much for your help! but I have already used roAudioPlayer now 🙂 and I think there is not much difference in using both the apporaches but both the players should be used for the purposes they are made for.

Using the roVideoPlayer gives you a few advantages over using the roAudioPlayer, the main one being the addition of isPositionNotification() events, which the roAudioPlayer doesn't provide. That aside, my point was, if destroying and recreating the roVideoPlayer component is causing a headache, then you could just re-purpose it for audio as well. I could be wrong, but I suspect the underlying component for the two is the same.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos