From 97592f9839576a4b92550c8abaf64e2da843b809 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 27 Oct 2023 13:22:06 -0400 Subject: [PATCH] Maximize video if playing on channel exit --- .../components/AppController/AppController.bs | 22 ++++++++++++++----- .../src/components/VideoPlayer/VideoUtils.bs | 17 +++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/playlet-lib/src/components/AppController/AppController.bs b/playlet-lib/src/components/AppController/AppController.bs index de0ca4e6..a89c4ee8 100644 --- a/playlet-lib/src/components/AppController/AppController.bs +++ b/playlet-lib/src/components/AppController/AppController.bs @@ -82,23 +82,35 @@ function onKeyEvent(key as string, press as boolean) as boolean return false end if if key = "options" - VideoUtils.ToggleVideoPictureInPicture() - return true + if VideoUtils.ToggleVideoPictureInPicture() + return true + end if end if if key = "play" - VideoUtils.TogglePause() + if VideoUtils.TogglePause() + return true + end if end if if key = "pause" - VideoUtils.PauseVideo() + if VideoUtils.PauseVideo() + return true + end if end if if key = "playonly" - VideoUtils.ResumeVideo() + if VideoUtils.ResumeVideo() + return true + end if end if if key = "back" + if VideoUtils.IsVideoPlayerOpen() and not VideoUtils.IsVideoPlayerFullScreen() + if VideoUtils.ToggleVideoPictureInPicture() + return true + end if + end if dialog = DialogUtils.ShowDialogButtons("Do you want to exit Playlet?", "Exit", ["Exit", "Cancel"]) dialog.observeField("buttonSelected", FuncName(OnExitDialog), ["buttonSelected"]) return true diff --git a/playlet-lib/src/components/VideoPlayer/VideoUtils.bs b/playlet-lib/src/components/VideoPlayer/VideoUtils.bs index 586d1d5d..60351498 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoUtils.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoUtils.bs @@ -85,32 +85,37 @@ namespace VideoUtils return GetVideoPlayer() <> invalid end function - function PauseVideo() as void + function PauseVideo() as boolean player = GetVideoPlayer() if player = invalid - return + return false end if player.control = "pause" + return true end function - function ResumeVideo() as void + function ResumeVideo() as boolean player = GetVideoPlayer() if player = invalid - return + return false end if player.control = "resume" + return true end function - function TogglePause() as void + function TogglePause() as boolean player = GetVideoPlayer() if player = invalid - return + return false end if if player.state = "playing" player.control = "pause" + return true else if player.state = "paused" player.control = "resume" + return true end if + return false end function end namespace