Add picture in picture animation
This commit is contained in:
1 parent
08dd620380
commit
ad861d38d5
3 files changed
+95
-41
No files matched your search
@@ -3,13 +3,26 @@ import "pkg:/components/Dialog/DialogUtils.bs"
|
|||||||
import "pkg:/source/roku_modules/rokupromise/Promise.brs"
|
import "pkg:/source/roku_modules/rokupromise/Promise.brs"
|
||||||
|
|
||||||
function PlayVideo(videoId as string, sender = invalid as object)
|
function PlayVideo(videoId as string, sender = invalid as object)
|
||||||
CloseVideo(false)
|
width = 1280
|
||||||
|
height = 720
|
||||||
|
translation = [0.0, 0.0]
|
||||||
videoContainer = GetVideoContainer()
|
videoContainer = GetVideoContainer()
|
||||||
|
if videoContainer.videoPlayer <> invalid
|
||||||
|
width = videoContainer.videoPlayer.width
|
||||||
|
height = videoContainer.videoPlayer.height
|
||||||
|
translation = videoContainer.videoPlayer.translation
|
||||||
|
end if
|
||||||
|
CloseVideo(false)
|
||||||
if sender <> invalid
|
if sender <> invalid
|
||||||
videoContainer.sender = sender
|
videoContainer.sender = sender
|
||||||
end if
|
end if
|
||||||
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
|
videoContainer.videoPlayer = videoContainer.createChild("VideoPlayer")
|
||||||
|
videoContainer.videoPlayer.id = "VideoPlayer"
|
||||||
videoContainer.videoPlayer.videoId = videoId
|
videoContainer.videoPlayer.videoId = videoId
|
||||||
|
videoContainer.videoPlayer.width = width
|
||||||
|
videoContainer.videoPlayer.height = height
|
||||||
|
videoContainer.videoPlayer.translation = translation
|
||||||
|
|
||||||
if videoContainer.fullscreen
|
if videoContainer.fullscreen
|
||||||
videoContainer.videoPlayer.SetFocus(true)
|
videoContainer.videoPlayer.SetFocus(true)
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -4,31 +4,25 @@ import "pkg:/components/VideoPlayer/Video.bs"
|
|||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
SetupSponsorBlock()
|
SetupSponsorBlock()
|
||||||
m.videoDetailsTask = m.top.findNode("VideoDetailsTask")
|
SetupAnimation()
|
||||||
' busySpinner is our spinner, shown when loading the video details (like links, title, etc)
|
|
||||||
m.busySpinner = m.top.findNode("BusySpinner")
|
|
||||||
' Once the Content is ready, the rokuBusySpinner shows up, which is loading the video feed
|
|
||||||
m.rokuBusySpinner = FindChildNodeOfType(m.top, "BusySpinner")
|
|
||||||
' The label that shows the buffering percentage
|
|
||||||
m.rokuBusySpinnerLabel = FindChildNodeOfType(m.rokuBusySpinner, "Label")
|
|
||||||
SetupBusySpinner()
|
SetupBusySpinner()
|
||||||
m.busySpinner.visible = true
|
|
||||||
m.busySpinner.control = "start"
|
|
||||||
|
|
||||||
m.videoPlayingSuccess = false
|
|
||||||
m.ignoreNextFinishedState = false
|
|
||||||
|
|
||||||
m.top.trickPlayBar.filledBarBlendColor = "0xFF0000FF"
|
m.top.trickPlayBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
m.top.bufferingBar.filledBarBlendColor = "0xFF0000FF"
|
m.top.bufferingBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
m.top.retrievingBar.filledBarBlendColor = "0xFF0000FF"
|
m.top.retrievingBar.filledBarBlendColor = "0xFF0000FF"
|
||||||
|
|
||||||
|
m.videoContainer = GetVideoContainer()
|
||||||
|
m.top.enableUI = m.videoContainer.fullscreen
|
||||||
|
m.videoContainer.observeFieldScoped("fullscreen", "OnFullScreenChange")
|
||||||
|
|
||||||
|
m.videoDetailsTask = m.top.findNode("VideoDetailsTask")
|
||||||
|
|
||||||
|
m.videoPlayingSuccess = false
|
||||||
|
m.ignoreNextFinishedState = false
|
||||||
|
|
||||||
m.top.observeField("control", "OnControlChange")
|
m.top.observeField("control", "OnControlChange")
|
||||||
m.top.observeField("videoId", "StartVideoDetailsTask")
|
m.top.observeField("videoId", "StartVideoDetailsTask")
|
||||||
|
|
||||||
m.videoContainer = GetVideoContainer()
|
|
||||||
m.videoContainer.observeFieldScoped("fullscreen", "OnFullScreenChange")
|
|
||||||
OnFullScreenChange()
|
|
||||||
|
|
||||||
m.top.ObserveField("state", "OnVideoPlayerStateChange")
|
m.top.ObserveField("state", "OnVideoPlayerStateChange")
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -126,19 +120,40 @@ function FindChildNodeOfType(node as object, nodeType as string) as object
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function SetupBusySpinner()
|
function SetupBusySpinner()
|
||||||
|
' busySpinner is our spinner, shown when loading the video details (like links, title, etc)
|
||||||
|
m.busySpinner = m.top.findNode("BusySpinner")
|
||||||
|
' Once the Content is ready, the rokuBusySpinner shows up, which is loading the video feed
|
||||||
|
m.rokuBusySpinner = FindChildNodeOfType(m.top, "BusySpinner")
|
||||||
|
' The label that shows the buffering percentage
|
||||||
|
m.rokuBusySpinnerLabel = FindChildNodeOfType(m.rokuBusySpinner, "Label")
|
||||||
|
|
||||||
m.rokuBusySpinner.poster.width = 150
|
m.rokuBusySpinner.poster.width = 150
|
||||||
m.rokuBusySpinner.poster.height = 150
|
m.rokuBusySpinner.poster.height = 150
|
||||||
m.rokuBusySpinner.poster.uri = "pkg:/images/spinner.png"
|
m.rokuBusySpinner.poster.uri = "pkg:/images/spinner.png"
|
||||||
m.rokuBusySpinner.observeField("translation", "OnRokuSpinnerMoved")
|
m.rokuBusySpinner.observeField("translation", "OnRokuSpinnerMoved")
|
||||||
|
m.top.observeField("width", "OnRokuSpinnerMoved")
|
||||||
|
m.top.observeField("height", "OnRokuSpinnerMoved")
|
||||||
|
m.top.observeField("translation", "OnRokuSpinnerMoved")
|
||||||
|
|
||||||
m.rokuBusySpinnerLabel.width = 150
|
m.rokuBusySpinnerLabel.width = 150
|
||||||
m.rokuBusySpinnerLabel.height = 150
|
m.rokuBusySpinnerLabel.height = 150
|
||||||
m.rokuBusySpinnerLabel.translation = [0, 0]
|
m.rokuBusySpinnerLabel.translation = [0, 0]
|
||||||
m.rokuBusySpinnerLabel.observeField("translation", "OnRokuSpinnerLabelMoved")
|
m.rokuBusySpinnerLabel.observeField("translation", "OnRokuSpinnerLabelMoved")
|
||||||
|
m.top.observeField("width", "OnRokuSpinnerLabelMoved")
|
||||||
|
m.top.observeField("height", "OnRokuSpinnerLabelMoved")
|
||||||
|
m.top.observeField("translation", "OnRokuSpinnerLabelMoved")
|
||||||
|
|
||||||
m.busySpinner.poster.width = 150
|
m.busySpinner.poster.width = 150
|
||||||
m.busySpinner.poster.height = 150
|
m.busySpinner.poster.height = 150
|
||||||
m.busySpinner.poster.uri = "pkg:/images/spinner.png"
|
m.busySpinner.poster.uri = "pkg:/images/spinner.png"
|
||||||
|
m.top.observeField("width", "PositionSpinner")
|
||||||
|
m.top.observeField("height", "PositionSpinner")
|
||||||
|
m.top.observeField("translation", "PositionSpinner")
|
||||||
|
|
||||||
|
PositionSpinner()
|
||||||
|
|
||||||
|
m.busySpinner.visible = true
|
||||||
|
m.busySpinner.control = "start"
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnRokuSpinnerMoved()
|
function OnRokuSpinnerMoved()
|
||||||
@@ -159,6 +174,12 @@ function OnRokuSpinnerLabelMoved()
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
function PositionSpinner()
|
||||||
|
centerx = (m.top.width - m.busySpinner.poster.width) / 2
|
||||||
|
centery = (m.top.height - m.busySpinner.poster.height) / 2
|
||||||
|
m.busySpinner.translation = [centerx, centery]
|
||||||
|
end function
|
||||||
|
|
||||||
function OnVideoPlayerStateChange() as void
|
function OnVideoPlayerStateChange() as void
|
||||||
state = m.top.state
|
state = m.top.state
|
||||||
|
|
||||||
@@ -213,31 +234,23 @@ function OnVideoPlayerStateChange() as void
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function OnFullScreenChange()
|
function SetupAnimation()
|
||||||
margin = 20
|
m.widthAnimation = m.top.findNode("widthAnimation")
|
||||||
width = 1280
|
m.widthAnimationInterpolator = m.top.findNode("widthAnimationInterpolator")
|
||||||
height = 720
|
m.heightAnimation = m.top.findNode("heightAnimation")
|
||||||
if m.videoContainer.fullscreen
|
m.heightAnimationInterpolator = m.top.findNode("heightAnimationInterpolator")
|
||||||
m.top.translation = [0, 0]
|
m.translationAnimation = m.top.findNode("translationAnimation")
|
||||||
m.top.width = width
|
m.translationAnimationInterpolator = m.top.findNode("translationAnimationInterpolator")
|
||||||
m.top.height = height
|
end function
|
||||||
else
|
|
||||||
small_width = width / 3
|
|
||||||
small_height = height / 3
|
|
||||||
x = width - small_width - margin
|
|
||||||
y = height - small_height - margin
|
|
||||||
|
|
||||||
m.top.translation = [x, y]
|
function OnFullScreenChange()
|
||||||
m.top.width = small_width
|
m.widthAnimationInterpolator.reverse = m.videoContainer.fullscreen
|
||||||
m.top.height = small_height
|
m.heightAnimationInterpolator.reverse = m.videoContainer.fullscreen
|
||||||
end if
|
m.translationAnimationInterpolator.reverse = m.videoContainer.fullscreen
|
||||||
|
|
||||||
|
m.widthAnimation.control = "start"
|
||||||
|
m.heightAnimation.control = "start"
|
||||||
|
m.translationAnimation.control = "start"
|
||||||
|
|
||||||
m.top.enableUI = m.videoContainer.fullscreen
|
m.top.enableUI = m.videoContainer.fullscreen
|
||||||
PositionSpinner()
|
|
||||||
end function
|
|
||||||
|
|
||||||
function PositionSpinner()
|
|
||||||
centerx = (m.top.width - m.busySpinner.poster.width) / 2
|
|
||||||
centery = (m.top.height - m.busySpinner.poster.height) / 2
|
|
||||||
m.busySpinner.translation = [centerx, centery]
|
|
||||||
end function
|
end function
|
||||||
@@ -31,5 +31,33 @@
|
|||||||
<BusySpinner
|
<BusySpinner
|
||||||
id="busySpinner"
|
id="busySpinner"
|
||||||
spinInterval="1" />
|
spinInterval="1" />
|
||||||
|
<Animation id="widthAnimation"
|
||||||
|
duration="0.3"
|
||||||
|
optional="true">
|
||||||
|
<FloatFieldInterpolator
|
||||||
|
id="widthAnimationInterpolator"
|
||||||
|
key="[0.0, 0.5, 1.0]"
|
||||||
|
keyValue="[ 1280.0, 853.0, 426.0 ]"
|
||||||
|
fieldToInterp="VideoPlayer.width" />
|
||||||
|
</Animation>
|
||||||
|
<Animation id="heightAnimation"
|
||||||
|
duration="0.3"
|
||||||
|
optional="true">
|
||||||
|
<FloatFieldInterpolator
|
||||||
|
id="heightAnimationInterpolator"
|
||||||
|
key="[0.0, 0.5, 1.0]"
|
||||||
|
keyValue="[ 720.0, 480.0, 240.0 ]"
|
||||||
|
fieldToInterp="VideoPlayer.height" />
|
||||||
|
</Animation>
|
||||||
|
<Animation
|
||||||
|
id="translationAnimation"
|
||||||
|
duration="0.3"
|
||||||
|
optional="true">
|
||||||
|
<Vector2DFieldInterpolator
|
||||||
|
id="translationAnimationInterpolator"
|
||||||
|
key="[0.0, 0.5, 1.0]"
|
||||||
|
keyValue="[ [0.0, 0.0], [417.0, 230.0], [834.0, 460.0] ]"
|
||||||
|
fieldToInterp="VideoPlayer.translation" />
|
||||||
|
</Animation>
|
||||||
</children>
|
</children>
|
||||||
</component>
|
</component>
|
||||||
Reference in new issue
Block a user