From f31eeed09d7727c0067d1cb7e0b5c11da0198e35 Mon Sep 17 00:00:00 2001 From: NotForMyCV <155258061+NotForMyCV@users.noreply.github.com> Date: Fri, 9 Aug 2024 00:41:40 +0100 Subject: [PATCH] [VideoScrollWheel] Fix infinite loop when scrolling near start/end (#392) --- plugins/VideoScrollWheel/VideoScrollWheel.js | 10 ++++++++++ plugins/VideoScrollWheel/VideoScrollWheel.yml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/VideoScrollWheel/VideoScrollWheel.js b/plugins/VideoScrollWheel/VideoScrollWheel.js index 81955e5e..f6c6df72 100644 --- a/plugins/VideoScrollWheel/VideoScrollWheel.js +++ b/plugins/VideoScrollWheel/VideoScrollWheel.js @@ -96,11 +96,21 @@ while (vjsPlayer.currentTime() < newTime) { vjsPlayer.currentTime(newTime + extraDelta); ++extraDelta; + + if (vjsPlayer.currentTime() + extraDelta >= vjsPlayer.duration()) { + vjsPlayer.currentTime(vjsPlayer.duration()); + break; + } } } else { while (vjsPlayer.currentTime() > newTime) { vjsPlayer.currentTime(newTime - extraDelta); ++extraDelta; + + if (vjsPlayer.currentTime() - extraDelta <= 0) { + vjsPlayer.currentTime(0); + break; + } } } } diff --git a/plugins/VideoScrollWheel/VideoScrollWheel.yml b/plugins/VideoScrollWheel/VideoScrollWheel.yml index 5cebaded..42c66cca 100644 --- a/plugins/VideoScrollWheel/VideoScrollWheel.yml +++ b/plugins/VideoScrollWheel/VideoScrollWheel.yml @@ -1,7 +1,7 @@ name: VideoScrollWheel # requires: CommunityScriptsUILibrary description: Adds functionality to change volume/time in scene video player by hovering over left/right side of player and scrolling with mouse scrollwheel. Scroll while hovering on left side to adjust volume, scroll on right side to skip forward/back. -version: 0.3 +version: 0.4 settings: allowVolumeChange: displayName: Volume change via mouse wheel