[skip ci] wip dev ui, needs state machine

This commit is contained in:
Brahim Hadriche committed 2024-06-29 11:59:38 -04:00
1 parent d223624f2e
commit a50fa3c347
3 files changed
+62 -11

No files matched your search

@@ -9,6 +9,7 @@ function VideoContentTaskDev(input as object) as object
invidiousNode = input.invidious
titleLabel.text = contentNode.title
secondaryTitleLabel.text = contentNode.secondaryTitle
if StringUtils.IsNullOrEmpty(contentNode.videoId)
throw "Can't load video information: videoId is missing"
@@ -24,7 +24,11 @@ function Init()
m.nextButton = m.top.findNode("NextButton")
m.minimizeButton = m.top.findNode("MinimizeButton")
m.trickPlayBar = m.top.findNode("TrickPlayBar")
m.videoUi = m.top.findNode("VideoUI")
m.progressTimer = m.top.findNode("ProgressTimer")
m.hideVideoUiTimer = m.top.findNode("HideVideoUiTimer")
m.fadeAnimation = m.top.findNode("FadeAnimation")
m.fadeOpacityInterpolator = m.top.findNode("FadeOpacityInterpolator")
SetupLoadingSpinner()
end function
@@ -46,6 +50,7 @@ function OnNodeReady()
DisposableObserveField(m.top, "bufferingStatus", FuncName(OnBufferingStatusChange))
DisposableObserveField(m.progressTimer, "fire", FuncName(OnProgress))
DisposableObserveField(m.hideVideoUiTimer, "fire", FuncName(OnHideVideoUiTimer))
SetNavigation(m.previousButton, "right", m.playButton)
SetNavigation(m.playButton, "right", m.nextButton)
@@ -56,14 +61,10 @@ function OnNodeReady()
SetNavigation(m.minimizeButton, "left", m.playButton)
SetNavigation(m.nextButton, "left", m.playButton)
SetNavigation(m.playButton, "left", m.previousButton)
end function
function OnFocusChange() as void
if not m.top.focus
return
if m.top.hasFocus() and m.videoUi.visible and m.videoUi.opacity = 1
NodeSetFocus(m.playButton, true)
end if
NodeSetFocus(m.playButton, true)
end function
function PlayWithContent(contentNode as object)
@@ -145,6 +146,12 @@ function OnClose()
end function
function OnkeyEvent(key as string, press as boolean) as boolean
m.hideVideoUiTimer.control = "stop"
m.hideVideoUiTimer.control = "start"
if ShowVideoUi()
return true
end if
if NavigationKeyHandler(key, press).handled
return true
end if
@@ -194,7 +201,7 @@ function OnPlayerStateChange() as void
state = m.top.state
if state = "stopping" or state = "stopped"
m.top.videoUiVisible = false
m.videoUi.Visible = false
return
end if
@@ -239,7 +246,13 @@ function OnProgress() as void
m.trickPlayBar.progress = m.top.position / duration
end function
function OnHideVideoUiTimer()
HideVideoUi()
end function
function OnDispose()
m.fadeAnimation.control = "stop"
m.hideVideoUiTimer.control = "stop"
m.fullScreenHintTimer.control = "stop"
m.loadingSpinner.control = "stop"
m.clock.dispose = true
@@ -296,7 +309,7 @@ function SetupMinimizeAnimation()
m.fullScreenHint.translation = [0, minRect.height - m.fullScreenHint.height]
m.top.showFullScreenHint = not fullscreen
m.top.videoUiVisible = fullscreen
m.videoUi.visible = fullscreen
DisposableObserveFieldScoped(m.container, "fullscreen", FuncName(OnFullScreenChange))
end function
@@ -309,7 +322,7 @@ function OnFullScreenChange()
m.translationInterpolator.reverse = fullscreen
m.minimizeAnimation.control = "start"
m.top.videoUiVisible = fullscreen
m.videoUi.visible = fullscreen
m.top.showFullScreenHint = not fullscreen
end function
@@ -339,3 +352,36 @@ function OnShowFullScreenHint() as void
m.fullScreenHintTimer.control = "start"
end function
function ShowVideoUi() as boolean
if m.fadeAnimation.state = "stopped"
if m.videoUi.opacity = 1
return false
end if
end if
m.fadeAnimation.control = "stop"
m.fadeOpacityInterpolator.reverse = false
m.fadeAnimation.control = "start"
if m.top.hasFocus()
NodeSetFocus(m.playButton, true)
end if
return true
end function
function HideVideoUi() as void
if m.fadeAnimation.state = "stopped"
if m.videoUi.opacity = 0
return
end if
end if
m.fadeAnimation.control = "stop"
m.fadeOpacityInterpolator.reverse = true
m.fadeAnimation.control = "start"
if m.top.isInFocusChain()
NodeSetFocus(m.top, true)
end if
end function
@@ -5,7 +5,7 @@
This would allow us to be flexible with the UI beyond the customizations
of the stock Roku Video component.
-->
<component name="VideoPlayerDev" extends="Video" includes="AutoBind,Focus,Disposable">
<component name="VideoPlayerDev" extends="Video" includes="AutoBind,Disposable">
<interface>
<field id="container" type="node" bind=".." />
<field id="videoQueue" type="node" bind="../../VideoQueue" />
@@ -14,7 +14,6 @@
<field id="minRect" type="rect2D" value="[834,460,426,240]" />
<field id="maxRect" type="rect2D" value="[0,0,1280,720]" />
<field id="showFullScreenHint" type="boolean" alwaysNotify="true" onChange="OnShowFullScreenHint" />
<field id="videoUiVisible" type="boolean" alias="VideoUI.visible" />
<field id="close" type="boolean" alwaysNotify="true" onChange="OnClose" />
<function name="PlayWithContent" />
</interface>
@@ -101,6 +100,11 @@
</Group>
</Group>
<Timer id="HideVideoUiTimer" duration="3" />
<Animation id="FadeAnimation" duration="0.3" optional="true">
<FloatFieldInterpolator id="FadeOpacityInterpolator" key="[0.0, 0.5, 1.0]" keyValue="[0.0, 0.5, 1.0]" fieldToInterp="VideoUI.opacity" />
</Animation>
<Animation id="minimizeAnimation" duration="0.3" optional="true">
<FloatFieldInterpolator id="widthInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.width" />
<FloatFieldInterpolator id="heightInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.height" />