Skip to content

Commit

Permalink
Merge pull request #23 from Vavency/master
Browse files Browse the repository at this point in the history
Add relative seeking
  • Loading branch information
Shadowsun™ authored Aug 17, 2023
2 parents 59469e3 + 35ec607 commit f073c3f
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ if SERVER then

if not IsVideoTimed(self:VideoType()) then return end

-- Get the plus or minus sign for later.
local frontsign = seconds[1] or ""

-- Seconds isn't a number, check HH:MM:SS
if not tonumber(seconds) then
local hr, min, sec = string.match(seconds, hhmmss)
Expand All @@ -512,6 +515,13 @@ if SERVER then
tonumber(sec)
end

-- If it's not one of those two things then it will fall trough wihtout any changes.
if frontsign == "+" then
seconds = self:VideoCurrentTime(true) + math.abs(seconds)
elseif frontsign == "-" then
seconds = self:VideoCurrentTime(true) - math.abs(seconds)
end

-- Clamp video seek time between 0 and video duration
seconds = math.Clamp(tonumber(seconds), 0, self:VideoDuration())

Expand Down

0 comments on commit f073c3f

Please sign in to comment.