From 90828da7e2b5a9e3df06c5b593398aad626f7e63 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 28 Jun 2024 19:08:11 -0400 Subject: [PATCH] progress bar prototype --- .../components/VideoPlayerDev/TrickPlayBar.bs | 16 ++++++++++ .../VideoPlayerDev/TrickPlayBar.xml | 27 +++++++++++++++++ .../VideoPlayerDev/VideoPlayerDev.bs | 28 +++++++++++++++++- .../VideoPlayerDev/VideoPlayerDev.xml | 13 ++++++-- playlet-lib/src/images/white-circle-xs.png | Bin 0 -> 239 bytes playlet-lib/src/images/white-circle.png | Bin 7451 -> 4689 bytes playlet-lib/src/images/white-circle.svg | 4 +++ .../src/images/white-circle.svg.meta.json5 | 17 +++++++++++ playlet-lib/src/images/white-pixel.png | Bin 0 -> 2795 bytes 9 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.bs create mode 100644 playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.xml create mode 100644 playlet-lib/src/images/white-circle-xs.png create mode 100644 playlet-lib/src/images/white-circle.svg create mode 100644 playlet-lib/src/images/white-circle.svg.meta.json5 create mode 100644 playlet-lib/src/images/white-pixel.png diff --git a/playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.bs b/playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.bs new file mode 100644 index 00000000..84725e90 --- /dev/null +++ b/playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.bs @@ -0,0 +1,16 @@ +const PROGRESS_WIDTH = 1144 +const PROGRESS_HEIGHT = 6 +const SEEK_HANDLE_WIDTH = 16 +const SEEK_HANDLE_HEIGHT = 16 + +function Init() + m.progressBar = m.top.findNode("ProgressBar") + m.seekHandle = m.top.findNode("SeekHandle") + OnProgressChange() +end function + +function OnProgressChange() + position = PROGRESS_WIDTH * m.top.progress + m.progressBar.width = position + m.seekHandle.translation = [position - SEEK_HANDLE_WIDTH / 2, (PROGRESS_HEIGHT - SEEK_HANDLE_HEIGHT) / 2] +end function diff --git a/playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.xml b/playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.xml new file mode 100644 index 00000000..28e6caad --- /dev/null +++ b/playlet-lib/src/components/VideoPlayerDev/TrickPlayBar.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs b/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs index 2089aa86..14bd4ab5 100644 --- a/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs +++ b/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs @@ -23,6 +23,8 @@ function Init() m.playButton = m.top.findNode("PlayButton") m.nextButton = m.top.findNode("NextButton") m.minimizeButton = m.top.findNode("MinimizeButton") + m.trickPlayBar = m.top.findNode("TrickPlayBar") + m.progressTimer = m.top.findNode("ProgressTimer") SetupLoadingSpinner() end function @@ -43,6 +45,8 @@ function OnNodeReady() DisposableObserveField(m.top, "state", FuncName(OnPlayerStateChange)) DisposableObserveField(m.top, "bufferingStatus", FuncName(OnBufferingStatusChange)) + DisposableObserveField(m.progressTimer, "fire", FuncName(OnProgress)) + SetNavigation(m.previousButton, "right", m.playButton) SetNavigation(m.playButton, "right", m.nextButton) SetNavigation(m.nextButton, "right", m.minimizeButton) @@ -186,12 +190,24 @@ function OnMinimizeButtonSelected() VideoQueueUtils.ToggleVideoPictureInPicture(m.videoQueue) end function -function OnPlayerStateChange() +function OnPlayerStateChange() as void state = m.top.state + + if state = "stopping" or state = "stopped" + m.top.videoUiVisible = false + return + end if + if state = "playing" m.playButton.toggleState = false ' Pause icon + m.playButton.disabled = false + + m.progressTimer.control = "start" else if state = "paused" m.playButton.toggleState = true ' Play icon + m.playButton.disabled = false + else + m.playButton.disabled = true end if if state = "buffering" @@ -213,6 +229,16 @@ function OnBufferingStatusChange() as void m.loadingPercentLabel.text = `${bufferingStatus.percentage}%` end function +function OnProgress() as void + duration = m.top.duration + if duration = 0 + m.trickPlayBar.progress = 0 + return + end if + + m.trickPlayBar.progress = m.top.position / duration +end function + function OnDispose() m.fullScreenHintTimer.control = "stop" m.loadingSpinner.control = "stop" diff --git a/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.xml b/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.xml index eefe1553..6a220c8b 100644 --- a/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.xml +++ b/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.xml @@ -62,7 +62,8 @@ + iconUri2="pkg:/images/icons/player/pause.png" + disabled="true" /> + + + + @@ -99,8 +106,8 @@ - -