picture-in-picture in dev player
This commit is contained in:
1 parent
ee8f7a05dd
commit
967d1840d0
6 files changed
+176
-38
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
import "pkg:/source/AsyncTask/Tasks.bs"
|
||||
import "pkg:/source/utils/DisposableObserve.bs"
|
||||
@@ -23,18 +24,27 @@ function Init()
|
||||
m.previousButton = m.top.findNode("PreviousButton")
|
||||
m.playButton = m.top.findNode("PlayButton")
|
||||
m.nextButton = m.top.findNode("NextButton")
|
||||
m.minimizeButton = m.top.findNode("MinimizeButton")
|
||||
|
||||
DisposableObserveFieldScoped(m.playButton, "buttonSelected", FuncName(OnPlayButtonSelected))
|
||||
DisposableObserveFieldScoped(m.minimizeButton, "buttonSelected", FuncName(OnMinimizeButtonSelected))
|
||||
|
||||
DisposableObserveField(m.top, "state", FuncName(OnPlayerStateChange))
|
||||
|
||||
SetNavigation(m.previousButton, "right", m.playButton)
|
||||
SetNavigation(m.playButton, "left", m.previousButton)
|
||||
SetNavigation(m.playButton, "right", m.nextButton)
|
||||
SetNavigation(m.nextButton, "right", m.minimizeButton)
|
||||
SetNavigation(m.playButton, "right", m.minimizeButton)
|
||||
|
||||
SetNavigation(m.minimizeButton, "left", m.nextButton)
|
||||
SetNavigation(m.minimizeButton, "left", m.playButton)
|
||||
SetNavigation(m.nextButton, "left", m.playButton)
|
||||
SetNavigation(m.playButton, "left", m.previousButton)
|
||||
end function
|
||||
|
||||
function OnNodeReady()
|
||||
SetupMinimizeAnimation()
|
||||
|
||||
DisposableObserveFieldScoped(m.videoQueue, "hasPrevious", FuncName(OnHasPreviousChange))
|
||||
DisposableObserveFieldScoped(m.videoQueue, "hasNext", FuncName(OnHasNextChange))
|
||||
OnHasPreviousChange()
|
||||
@@ -167,6 +177,10 @@ function OnNextButtonSelected()
|
||||
m.videoQueue.next = true
|
||||
end function
|
||||
|
||||
function OnMinimizeButtonSelected()
|
||||
VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue)
|
||||
end function
|
||||
|
||||
function OnPlayerStateChange()
|
||||
state = m.top.state
|
||||
if state = "playing"
|
||||
@@ -180,3 +194,80 @@ function OnDispose()
|
||||
m.clock.dispose = true
|
||||
DisposeObservers()
|
||||
end function
|
||||
|
||||
function SetupMinimizeAnimation()
|
||||
m.fullScreenHint = m.top.findNode("fullScreenHint")
|
||||
m.fullScreenHintLabel = m.top.findNode("fullScreenHintLabel")
|
||||
m.fullScreenHintTimer = m.top.findNode("fullScreenHintTimer")
|
||||
m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer))
|
||||
|
||||
m.minimizeAnimation = m.top.findNode("minimizeAnimation")
|
||||
m.widthInterpolator = m.top.findNode("widthInterpolator")
|
||||
m.heightInterpolator = m.top.findNode("heightInterpolator")
|
||||
m.translationInterpolator = m.top.findNode("translationInterpolator")
|
||||
|
||||
minRect = m.top.minRect
|
||||
maxRect = m.top.maxRect
|
||||
|
||||
m.widthInterpolator.keyValue = [maxRect.width, (maxRect.width + minRect.width) / 2, minRect.width]
|
||||
m.heightInterpolator.keyValue = [maxRect.height, (maxRect.height + minRect.height) / 2, minRect.height]
|
||||
maxTranslation = [maxRect.x, maxRect.y]
|
||||
minTranslation = [minRect.x, minRect.y]
|
||||
midTranslation = [(maxRect.x + minRect.x) / 2, (maxRect.y + minRect.y) / 2]
|
||||
m.translationInterpolator.keyValue = [maxTranslation, midTranslation, minTranslation]
|
||||
|
||||
fullscreen = m.container.fullscreen
|
||||
rect = fullscreen ? maxRect : minRect
|
||||
|
||||
m.top.width = rect.width
|
||||
m.top.height = rect.height
|
||||
m.top.translation = [rect.x, rect.y]
|
||||
|
||||
m.fullScreenHint.width = minRect.width
|
||||
m.fullScreenHintLabel.width = minRect.width
|
||||
m.fullScreenHint.translation = [0, minRect.height - m.fullScreenHint.height]
|
||||
|
||||
m.top.showFullScreenHint = not fullscreen
|
||||
m.top.videoUiVisible = fullscreen
|
||||
|
||||
m.container.observeFieldScoped("fullscreen", FuncName(OnFullScreenChange))
|
||||
end function
|
||||
|
||||
function OnFullScreenChange()
|
||||
fullscreen = m.container.fullscreen
|
||||
|
||||
m.widthInterpolator.reverse = fullscreen
|
||||
m.heightInterpolator.reverse = fullscreen
|
||||
m.translationInterpolator.reverse = fullscreen
|
||||
m.minimizeAnimation.control = "start"
|
||||
|
||||
m.top.videoUiVisible = fullscreen
|
||||
m.top.showFullScreenHint = not fullscreen
|
||||
end function
|
||||
|
||||
function OnFullScreenHintTimer()
|
||||
showFullScreenHint = m.top.showFullScreenHint
|
||||
m.fullScreenHint.visible = showFullScreenHint
|
||||
if showFullScreenHint
|
||||
m.top.showFullScreenHint = false
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnShowFullScreenHint() as void
|
||||
m.fullScreenHintTimer.control = "stop"
|
||||
|
||||
if m.container.fullscreen
|
||||
m.fullScreenHint.visible = false
|
||||
return
|
||||
end if
|
||||
|
||||
if m.top.showFullScreenHint
|
||||
' Take 1 second until the shrink animation finishes to show the hint
|
||||
m.fullScreenHintTimer.duration = 1
|
||||
else
|
||||
' Wait 5 seconds then hide the hint
|
||||
m.fullScreenHintTimer.duration = 5
|
||||
end if
|
||||
|
||||
m.fullScreenHintTimer.control = "start"
|
||||
end function
|
||||
@@ -7,9 +7,14 @@
|
||||
-->
|
||||
<component name="VideoPlayerDev" extends="Video" includes="AutoBind,Focus,Disposable">
|
||||
<interface>
|
||||
<field id="container" type="node" bind=".." />
|
||||
<field id="videoQueue" type="node" bind="../../VideoQueue" />
|
||||
<field id="invidious" type="node" bind="../../Invidious" />
|
||||
<field id="previousPlayer" type="node" />
|
||||
<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>
|
||||
@@ -21,46 +26,62 @@
|
||||
horizOrigin="right"
|
||||
translation="[1280,0]" />
|
||||
|
||||
<Group id="TopUI">
|
||||
<!--
|
||||
<Group id="VideoUI">
|
||||
|
||||
<Group id="TopUI">
|
||||
<!--
|
||||
TODO:P2 once VideoPlayerDev replaces VideoPlayer, the clock can
|
||||
be removed to reuse the Clock from MainScene
|
||||
-->
|
||||
<Clock id="Clock" />
|
||||
<LayoutGroup
|
||||
itemSpacings="[5]"
|
||||
translation="[68,40]">
|
||||
<Label
|
||||
id="TitleLabel"
|
||||
font="font:LargeBoldSystemFont"
|
||||
width="900"
|
||||
wrap="true" />
|
||||
<Label
|
||||
id="SecondaryTitleLabel"
|
||||
font="font:SmallestSystemFont"
|
||||
width="900"
|
||||
wrap="true" />
|
||||
</LayoutGroup>
|
||||
</Group>
|
||||
<Group>
|
||||
<LayoutGroup
|
||||
layoutDirection="horiz"
|
||||
horizAlignment="center"
|
||||
itemSpacings="[15]"
|
||||
translation="[640,600]">
|
||||
<VideoPlayerButton
|
||||
id="PreviousButton"
|
||||
iconUri="pkg:/images/icons/player/previous.png"
|
||||
disabled="true" />
|
||||
<VideoPlayerButton
|
||||
id="PlayButton"
|
||||
iconUri="pkg:/images/icons/player/play.png"
|
||||
iconUri2="pkg:/images/icons/player/pause.png" />
|
||||
<VideoPlayerButton
|
||||
id="NextButton"
|
||||
iconUri="pkg:/images/icons/player/next.png"
|
||||
disabled="true" />
|
||||
</LayoutGroup>
|
||||
<Clock id="Clock" />
|
||||
<LayoutGroup
|
||||
itemSpacings="[5]"
|
||||
translation="[68,40]">
|
||||
<Label
|
||||
id="TitleLabel"
|
||||
font="font:LargeBoldSystemFont"
|
||||
width="900"
|
||||
wrap="true" />
|
||||
<Label
|
||||
id="SecondaryTitleLabel"
|
||||
font="font:SmallestSystemFont"
|
||||
width="900"
|
||||
wrap="true" />
|
||||
</LayoutGroup>
|
||||
</Group>
|
||||
<Group>
|
||||
<LayoutGroup
|
||||
layoutDirection="horiz"
|
||||
horizAlignment="left"
|
||||
itemSpacings="[15,15,50]"
|
||||
translation="[562,600]">
|
||||
<VideoPlayerButton
|
||||
id="PreviousButton"
|
||||
iconUri="pkg:/images/icons/player/previous.png"
|
||||
disabled="true" />
|
||||
<VideoPlayerButton
|
||||
id="PlayButton"
|
||||
iconUri="pkg:/images/icons/player/play.png"
|
||||
iconUri2="pkg:/images/icons/player/pause.png" />
|
||||
<VideoPlayerButton
|
||||
id="NextButton"
|
||||
iconUri="pkg:/images/icons/player/next.png"
|
||||
disabled="true" />
|
||||
<VideoPlayerButton
|
||||
id="MinimizeButton"
|
||||
iconUri="pkg:/images/icons/player/minimize.png" />
|
||||
</LayoutGroup>
|
||||
</Group>
|
||||
</Group>
|
||||
|
||||
<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" />
|
||||
<Vector2DFieldInterpolator id="translationInterpolator" key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.translation" />
|
||||
</Animation>
|
||||
<Rectangle id="fullScreenHint" height="26" color="0x000000" opacity="0.8" visible="false">
|
||||
<Label id="fullScreenHintLabel" text="Press Options (*) for full screen" height="26" color="0xFFFFFF" horizAlign="center" vertAlign="center" font="font:SmallestSystemFont" />
|
||||
<Timer id="fullScreenHintTimer" duration="5" />
|
||||
</Rectangle>
|
||||
</children>
|
||||
</component>
|
||||
@@ -1,3 +1,4 @@
|
||||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
||||
import "pkg:/source/utils/FocusManagement.bs"
|
||||
|
||||
namespace VideoQueueUtils
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 380 B |
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
viewBox="0 0 36 36"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<g
|
||||
transform="translate(0,9)">
|
||||
<path
|
||||
fill="#FFFF"
|
||||
d="m 27,0 a 1,1 0 0 1 1,1 V 8 H 26 V 2 H 10 v 14 h 6 v 2 H 9 A 1,1 0 0 1 8,17 V 1 A 1,1 0 0 1 9,0 Z m 0,10 a 1,1 0 0 1 1,1 v 6 a 1,1 0 0 1 -1,1 h -8 a 1,1 0 0 1 -1,-1 v -6 a 1,1 0 0 1 1,-1 z M 12.707,3.293 14.957,5.543 17,3.5 V 9 h -5.5 l 2.043,-2.043 -2.25,-2.25 z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 572 B |
@@ -0,0 +1,11 @@
|
||||
{
|
||||
inputHash: 'ab2981fe4384e5a43c1169f46acf6415',
|
||||
outputs: [
|
||||
{
|
||||
outputFilePath: 'images/icons/player/minimize.png',
|
||||
outputHash: '379093375a65767078d58a6b1d9370c3',
|
||||
width: 48,
|
||||
height: 48,
|
||||
},
|
||||
],
|
||||
}
|
||||
Reference in new issue
Block a user