kane2931
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2017
06:01 PM
Audio Node
I try to get the audio keeps playing when the user scroll up and down in a list (of radio stations), i am using AudioExemple template. What i would like to be able to do, is scrubbing the listing, then when the user press ok (for selecting a new station), it stops the current (station) and start playing the new one.
Now every time the user touch the remote, audio stops. š
Now every time the user touch the remote, audio stops. š
<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp. All Rights Reserved. **********-->
<component name = "AudioScene" extends = "Scene" >
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.backgroundURI = "pkg:/images/rsgetbg.png"
m.audiolist = m.top.findNode("audioLabelList")
m.audioposter = m.top.findNode("audioPoster")
m.audiolist.observeField("itemFocused","setaudio")
m.audiolist.observeField("itemSelected","playaudio")
m.audio = createObject("RoSGNode","Audio")
m.audio.observeField("state","controlaudioplay")
m.readAudioContentTask = createObject("RoSGNode","AudioContentReader")
m.readAudioContentTask.observeField("audiocontent","showaudiolist")
m.readAudioContentTask.audiocontenturi = "pkg:/server/audiocontent.xml"
m.readAudioContentTask.control = "RUN"
end sub
sub showaudiolist()
m.audiolist.content = m.readAudioContentTask.audiocontent
m.audiolist.setFocus(true)
end sub
sub setaudio()
audiocontent = m.audiolist.content.getChild(m.audiolist.itemFocused)
m.audioposter.uri = audiocontent.hdposterurl
m.audio.content = audiocontent
end sub
sub playaudio()
m.audio.control = "stop"
m.audio.control = "none"
m.audio.control = "play"
end sub
sub controlaudioplay()
if (m.audio.state = "finished")
m.audio.control = "stop"
m.audio.control = "none"
end if
end sub
function onKeyEvent(key as String,press as Boolean) as Boolean
if press then
if key = "back"
if (m.audio.state = "playing")
m.audio.control = "stop"
return true
end if
end if
end if
return false
end function
]]>
</script>
<children>
<Group >
<LabelList
id = "audioLabelList"
color="0x000000"
itemSize = "[ 360, 60 ]"
translation = "[ 90, 60 ]">
<Font
role = "font"
uri = "pkg:/fonts/avenirltstd-light-webfont.ttf"
id = "avenir-light"
size = "26"/>
</LabelList>
<Poster
id = "audioPoster"
translation = "[ 844, 150 ]"
width = "300"
height = "300" />
</Group>
</children>
</component>
2 REPLIES 2
Tyler_Smith
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-07-2017
10:14 PM
Re: Audio Node
Remove m.audiolist.observeField("itemFocused","setaudio") and combine your setAudio and playAudio subroutines like I have below.
<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp. All Rights Reserved. **********-->
<component name = "AudioScene" extends = "Scene" >
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.backgroundURI = "pkg:/images/rsgetbg.png"
m.audiolist = m.top.findNode("audioLabelList")
m.audioposter = m.top.findNode("audioPoster")
m.audiolist.observeField("itemFocused","setaudio")
m.audiolist.observeField("itemSelected","playaudio")
m.audio = createObject("RoSGNode","Audio")
m.audio.observeField("state","controlaudioplay")
m.readAudioContentTask = createObject("RoSGNode","AudioContentReader")
m.readAudioContentTask.observeField("audiocontent","showaudiolist")
m.readAudioContentTask.audiocontenturi = "pkg:/server/audiocontent.xml"
m.readAudioContentTask.control = "RUN"
end sub
sub showaudiolist()
m.audiolist.content = m.readAudioContentTask.audiocontent
m.audiolist.setFocus(true)
end sub
sub playaudio()
audiocontent = m.audiolist.content.getChild(m.audiolist.itemFocused)
m.audioposter.uri = audiocontent.hdposterurl[/font][/size]
m.audio.content = audiocontent
m.audio.control = "stop"
m.audio.control = "none"
m.audio.control = "play"
end sub
sub controlaudioplay()
if (m.audio.state = "finished")
m.audio.control = "stop"
m.audio.control = "none"
end if
end sub
function onKeyEvent(key as String,press as Boolean) as Boolean
if press then
if key = "back"
if (m.audio.state = "playing")
m.audio.control = "stop"
return true
end if
end if
end if
return false
end function
]]>
</script>
<children>
<Group >
<LabelList
id = "audioLabelList"
color="0x000000"
itemSize = "[ 360, 60 ]"
translation = "[ 90, 60 ]">
<Font
role = "font"
uri = "pkg:/fonts/avenirltstd-light-webfont.ttf"
id = "avenir-light"
size = "26"/>
</LabelList>
<Poster
id = "audioPoster"
translation = "[ 844, 150 ]"
width = "300"
height = "300" />
</Group>
</children>
</component>
Tyler Smith
kane2931
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-09-2017
09:07 AM
Re: Audio Node
"Tyler Smith" wrote:
Remove m.audiolist.observeField("itemFocused","setaudio") and combine your setAudio and playAudio subroutines like I have below.<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2016 Roku Corp. All Rights Reserved. **********-->
<component name = "AudioScene" extends = "Scene" >
<script type = "text/brightscript" >
<![CDATA[
sub init()
m.top.backgroundURI = "pkg:/images/rsgetbg.png"
m.audiolist = m.top.findNode("audioLabelList")
m.audioposter = m.top.findNode("audioPoster")
m.audiolist.observeField("itemFocused","setaudio")
m.audiolist.observeField("itemSelected","playaudio")
m.audio = createObject("RoSGNode","Audio")
m.audio.observeField("state","controlaudioplay")
m.readAudioContentTask = createObject("RoSGNode","AudioContentReader")
m.readAudioContentTask.observeField("audiocontent","showaudiolist")
m.readAudioContentTask.audiocontenturi = "pkg:/server/audiocontent.xml"
m.readAudioContentTask.control = "RUN"
end sub
sub showaudiolist()
m.audiolist.content = m.readAudioContentTask.audiocontent
m.audiolist.setFocus(true)
end sub
sub playaudio()
audiocontent = m.audiolist.content.getChild(m.audiolist.itemFocused)
m.audioposter.uri = audiocontent.hdposterurl[/font][/size]
m.audio.content = audiocontent
m.audio.control = "stop"
m.audio.control = "none"
m.audio.control = "play"
end sub
sub controlaudioplay()
if (m.audio.state = "finished")
m.audio.control = "stop"
m.audio.control = "none"
end if
end sub
function onKeyEvent(key as String,press as Boolean) as Boolean
if press then
if key = "back"
if (m.audio.state = "playing")
m.audio.control = "stop"
return true
end if
end if
end if
return false
end function
]]>
</script>
<children>
<Group >
<LabelList
id = "audioLabelList"
color="0x000000"
itemSize = "[ 360, 60 ]"
translation = "[ 90, 60 ]">
<Font
role = "font"
uri = "pkg:/fonts/avenirltstd-light-webfont.ttf"
id = "avenir-light"
size = "26"/>
</LabelList>
<Poster
id = "audioPoster"
translation = "[ 844, 150 ]"
width = "300"
height = "300" />
</Group>
</children>
</component>
Thank you so much it worked ! š