Skip to content

Commit

Permalink
[VideoScrollWheel] Fix infinite loop when scrolling near start/end (#392
Browse files Browse the repository at this point in the history
)
  • Loading branch information
NotForMyCV authored Aug 8, 2024
1 parent 108f14d commit f31eeed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions plugins/VideoScrollWheel/VideoScrollWheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/VideoScrollWheel/VideoScrollWheel.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit f31eeed

Please sign in to comment.