diff --git a/CHANGELOG.md b/CHANGELOG.md index 590bb7cd..1c8b32fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Support to pause/play while picture-in-picture + ## [0.13.0] - 2023-10-02 ### Added diff --git a/playlet-lib/src/components/AppController/AppController.bs b/playlet-lib/src/components/AppController/AppController.bs index 2b8fca5d..de0ca4e6 100644 --- a/playlet-lib/src/components/AppController/AppController.bs +++ b/playlet-lib/src/components/AppController/AppController.bs @@ -83,7 +83,22 @@ function onKeyEvent(key as string, press as boolean) as boolean end if if key = "options" VideoUtils.ToggleVideoPictureInPicture() - else if key = "back" + return true + end if + + if key = "play" + VideoUtils.TogglePause() + end if + + if key = "pause" + VideoUtils.PauseVideo() + end if + + if key = "playonly" + VideoUtils.ResumeVideo() + end if + + if key = "back" 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 35e8198c..29fb1c8a 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoUtils.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoUtils.bs @@ -81,6 +81,18 @@ namespace VideoUtils player.control = "resume" end function + function TogglePause() as void + player = GetVideoPlayer() + if player = invalid + return + end if + if player.state = "playing" + player.control = "pause" + else if player.state = "paused" + player.control = "resume" + end if + end function + end namespace