From e6302e48fe43f2a347de1fbb6e288b00423202ae Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 11 Jan 2024 14:56:41 -0500 Subject: [PATCH] Full screen hint (#264) --- CHANGELOG.md | 4 ++ .../src/components/VideoPlayer/VideoPlayer.bs | 40 ++++++++++++++++++- .../components/VideoPlayer/VideoPlayer.xml | 20 ++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daf019f6..9bb4ad2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- A hint on how to restore video to full screen + ### Changed - Bookmarks are now added to the top of the list diff --git a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs index 3093717d..5f645025 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs @@ -11,6 +11,10 @@ import "pkg:/source/utils/Logging.bs" function Init() SetPlayerStyle() SetupAnimation() + m.fullScreenHint = m.top.findNode("fullScreenHint") + m.fullScreenHintLabel = m.top.findNode("fullScreenHintLabel") + m.fullScreenHintTimer = m.top.findNode("fullScreenHintTimer") + m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer)) ' videoPlayingSuccess indicates if we started playing a video successfully ' We use it to detect if we should try another link for a video, or if another error @@ -33,14 +37,20 @@ function Init() end function function OnNodeReady() - rect = m.container.fullscreen ? m.top.maxRect : m.top.minRect + minRect = m.top.minRect + rect = m.container.fullscreen ? m.top.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] + ' TODO:P2 show a loading spinner if video is loading minimized m.top.enableUI = m.container.fullscreen + m.top.showFullScreenHint = not m.container.fullscreen m.container.observeFieldScoped("fullscreen", FuncName(OnFullScreenChange)) m.top.ObserveField("state", FuncName(OnVideoPlayerStateChange)) @@ -319,6 +329,34 @@ function OnFullScreenChange() m.minimizeAnimation.control = "start" m.top.enableUI = m.container.fullscreen + m.top.showFullScreenHint = not m.container.fullscreen SponsorBlock.SetVisible(m.notifications, m.container.fullscreen) 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 + +function OnFullScreenHintTimer() + showFullScreenHint = m.top.showFullScreenHint + m.fullScreenHint.visible = showFullScreenHint + if showFullScreenHint + m.top.showFullScreenHint = false + end if +end function diff --git a/playlet-lib/src/components/VideoPlayer/VideoPlayer.xml b/playlet-lib/src/components/VideoPlayer/VideoPlayer.xml index 368a15a2..4f52a825 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoPlayer.xml +++ b/playlet-lib/src/components/VideoPlayer/VideoPlayer.xml @@ -10,6 +10,7 @@ + @@ -43,5 +44,24 @@ key="[0.0, 0.5, 1.0]" fieldToInterp="VideoPlayer.translation" /> + + \ No newline at end of file