<?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>
"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>
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. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 19th and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
We're sorry for this disruption — we’re excited to share what’s next!