When I extend Video Node, I don't want my extended node to process any key pressings but "play", so I first wrote this:
function onKeyEvent(key as String, press as Booelan) as boolean
if(key <> "play")
return true
end if
return false
end function
with this key-event, when I start playing content in my VideoE in my scene, I can press "play" and it is handled correctly, but any other key-pressings are not handled by scene(such as arrow-keys which I use for navigation).
after that I tried this function:
function onKeyEvent(key as String, press as boolean) as boolean
print key
return true
end function
this gives me no reaction of VideoE on any key even on "play" and also it isn't handled by scene.
then I tried
function onKeyEvent(key as String, press as boolean) as boolean
print key
return false
end function
with this function: my navigation on scene works only when content isn't set; after the content is set and playing, arrow-keys are handled by VideoE, which isn't allowed for me.
I need arrow-keys to be handled by scene, and VideoE to process only "play" button(fastforward and rewind are also accepted). How can I make this?
here's full xml-code
<?xml version="1.0" encoding="utf-8"?>
<component name="VideoE" extends="Video">
<interface>
<field id="showStats" type="bool" onChange="setEngineeringMode" value = "false"/>
</interface>
<script type="text/brightscript">
<![CDATA[
sub init()
m.top.observeField("focusedChild", "showFocused")
setEngineeringMode()
end sub
function onKeyEvent(key as String, press as boolean) as boolean
print key
return true
end function
sub showFocused()
if(m.top.isInFocusChain())
m.top.FindNode("FocusAnimation").control = "start"
print "Focused"
else
m.top.FindNode("UnfocusAnimation").control = "start"
print "Unfocused"
end if
print m.top.hasFocus()
end sub
]]>
</script>
<children>
<Poster
id="RectViolet"
translation = "[-5, -5]"
uri="pkg:/images/rect_violet_640_360.png"
opacity = "0" />
<Animation
id="FocusAnimation"
duration="0.7"
repeat="false"
easeFunction="linear">
<FloatFieldInterpolator
id="fadeInInterp"
key = "[0.0, 0.5, 1.0]"
keyValue = "[ 0.0, 0.5, 1.0]"
fieldToInterp="RectViolet.opacity"/>
</Animation>
<Animation
id="UnfocusAnimation"
duration="0.7"
repeat="false"
easeFunction="linear">
<FloatFieldInterpolator
id="fadeoutInterp"
key = "[0.0, 0.5, 1.0]"
keyValue = "[ 1.0, 0.5, 0.0]"
fieldToInterp="RectViolet.opacity"/>
</Animation>
</children>
</component>