Hi RokuJonathanD ,
Sorry for the late reply. I'm using an Audio node. I've inserted the code from the XML and the BRS files respectively. The primeRadio function loads the contentNode from a TaskNode to the audio player. I then make sure the Scene gets the focus not the audio player, hoping this would solve the problem. Unfortunately as long as the audio player is playing and not "stop" then the keyevent never gets propagated up the chain. I've also added the onKeyEvent function to show I don't process the "*" key.
I'd prefer sending you full source files outside this thread to maintain source integrity, and we could update this thread with impending solution if any.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 Xystra, Inc. All rights reserved. -->
<component
name="RadioGridView"
extends="SGDEXComponent"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd"
>
<interface>
<function name="switchMode" />
</interface>
<script type="text/brightscript" uri="RadioGridView.brs" />
<script type="text/brightscript" uri="pkg:/components/AppUtils.brs" />
<script type="text/brightscript" uri="pkg:/components/SGDEX/Views/utils/Utils.brs" />
<children>
<!-- Background, randomly selected -->
<Poster
uri="pkg:/images/background/blue.png"
width="1920.0"
height="1080.0"
translation="[0, 0]"
/>
<!-- Main Audio component -->
<Audio
id="streamPlayer"
/>
<!-- Headline -->
<Group>
<Poster
uri="pkg:/images/logo.png"
width="75"
height="75"
translation="[50.0, 60.0]"
/>
<Label
id="radioHeadline"
translation="[135, 30]"
maxLines="1"
/>
<Label
id="radioMoto"
translation="[135, 150]"
horizAlign="left"
/>
</Group>
<!-- Now Playing component -->
<Group
id="nowStreaming"
visible="true"
>
<Poster
uri="pkg:/images/background/nowplaying.9.png"
width="801"
height="300"
translation="[1120.0, 100.0]"
/>
<Poster
id="nowPlayingLogo"
width="200"
height="200"
translation="[1200, 150]"
/>
<Label
id="nowPlayingStation"
translation="[1430.0, 140.0]"
horizAlign="left"
/>
<Label
id="nowPlayingLocation"
translation="[1430.0, 180.0]"
horizAlign="left"
/>
<Label
id="nowPlayingRDSHeader"
translation="[1430.0, 230.0]"
horizAlign="left"
/>
<Label
id="nowPlayingRDS"
translation="[1430.0, 255.0]"
horizAlign="left"
width="420"
wrap="false"
ellipsizeOnBoundary="true"
/>
<Poster
id="nowPlayingControl"
height="75"
width="75"
translation="[1480.0, 290.0]"
/>
<Poster
id="nowPlayingFavorite"
height="75"
width="75"
translation="[1570.0, 290.0]"
/>
</Group>
<!-- RowList of channels -->
<RowList
id="stationList"
translation="[ 100, 400 ]"
itemComponentName="stationItem"
numRows="4"
itemSize="[ 1720, 250 ]"
rowItemSize="[ [170, 170] ]"
rowItemSpacing="[ [ 50, 0 ] ]"
showRowLabel="[ true ]"
drawFocusFeedback="true"
focusBitmapUri="pkg:/images/background/stationfocus.9.png"
rowFocusAnimationStyle="floatingFocus"
/>
<Timer
id="rdsTimer"
repeat="true"
duration="5"
/>
<!-- Aux features controls -->
<Group>
<Poster
uri="pkg:/images/star.png"
width="40.0"
height="40.0"
translation="[1560,10]" />
<Label
id="menuLabel"
translation="[1610, 15]"
wrap="false"
/>
</Group>
<Group
id="busySpinner"
visible="false"
>
<Poster
uri="pkg:/images/background/modal.png"
width="1920"
height="1080"
translation="[0.0,0.0]"
/>
<BusySpinner
id="spinner"
translation="[960, 540]"
/>
<Label
id="busyLoading"
translation="[820, 650]"
/>
</Group>
</children>
</component>
sub primeRadio()
print "Starting playback: " + m.playTask.stationContent.title
m.current = m.playTask.stationContent
m.tgRegistry.Write("lastRadio", m.current.id)
m.tgRegistry.Flush()
m.nowPlayingStation.text = m.playTask.stationContent.title
m.nowPlayingLocation.text = m.playTask.stationContent.location
m.nowPlayingLogo.uri = "<link to png file>"
m.nowPlayingRDS.text = "Not available"
if m.playTask.stationContent.rds then
startRDSTimer()
end if
favsJson = m.tgRegistry.Read("radioFavorites")
favorites = ParseJson(favsJson)
m.currentIsFavorite = false
for each fav in favorites
if fav.id = m.current.id then
m.currentIsFavorite = true
end if
end for
if m.currentIsFavorite then
m.nowPlayingFavorite.uri = "pkg:/images/heart-focus.png"
else
m.nowPlayingFavorite.uri = "pkg:/images/heart-off.png"
end if
m.nowPlayingControl.uri = "pkg:/images/pause.png"
m.audioPlayer.content = m.playTask.stationContent
m.audioPlayer.control = "play"
m.top.getScene().setFocus(true)
if not m.isSubGroup then
ShowSpinner(false)
end if
end sub
function onKeyEvent(_key_ as String, _press_ as Boolean) as Boolean
handled = false
if _press_ then
? _key_ + " pressed."
if _key_ = "down" then
if not m.stationList.hasFocus() then
m.stationList.setFocus(true)
handled = True
end if
end if
if _key_ = "up" then
m.nowPlayingControl.setFocus(true)
end if
if _key_ = "left" or _key_ = "right" then
if not m.stationList.hasFocus() then
if m.nowPlayingControl.hasFocus() then
m.nowPlayingFavorite.setFocus(true)
else
m.nowPlayingControl.setFocus(true)
end if
handled = True
end if
end if
if _key_ = "OK" then
if m.nowPlayingControl.hasFocus() then
OnNowPlayingControlSelected()
handled = True
else if m.nowPlayingFavorite.hasFocus() then
OnNowPlayingFavoriteSelected()
handled = True
end if
end if
'keys not used in fullscreen
if _key_ = "replay" or _key_ = "play" or _key_ = "rewind" or _key_ = "fastforward" then
handled = true
end if
end if
return handled
end function