Video TimePosition Event trick!

Continuing the discussion from VideoFrame TimePosition does not fire a property changed signal:

You can try it untill then,

local VideoHandler = {}

function VideoHandler:PauseOnTime(VideoFrame :VideoFrame, finalTime, onComplete :()->(), onFailed :()->())

local maxTimer = 5
repeat maxTimer -= 0.1 wait(0.1) until VideoFrame.IsLoaded or maxTimer <= 0

if not VideoFrame.IsLoaded then
	
	if onFailed then
		onFailed()
	end
	
	return
	
end

VideoFrame:Play()

local max = 30

task.spawn(function()
	
	while task.wait(0.05) do
		local VTP = VideoFrame.TimePosition
		if VTP >= finalTime then
			if onComplete then
				onComplete()
			end
			break
		end
		
		max -= 0.05
		
		if max<=0 then
			break
		end
		
	end 
end)

end

return VideoHandler

1 Like