improved video player

Run Settings
LanguageLua
Language Version
Run Command
local VideoCollection = loadstring(game:GetService("HttpService"):GetAsync("https://glot.io/snippets/gur7rc9dq6/raw/data.lua",true))() local args = {...} local ChosenVideo = VideoCollection[args[1]] local horizontal = ChosenVideo.horizontal local frames = ChosenVideo.frames local fps = ChosenVideo.fps local Main = Instance.new("Part",script) Main.Anchored = true Main.Transparency = 0 Main.Size = (not horizontal and Vector3.new(6.6, 14.031, 0.096) or Vector3.new(18.3, 10.831, 0.096)) Main.CFrame = owner.Character.HumanoidRootPart.CFrame * CFrame.new(0,5,-5) * CFrame.Angles(0,math.rad(180),0) local Surface = Instance.new("SurfaceGui",Main) local PrimaryFrame = Instance.new("Frame",Surface) PrimaryFrame.ClipsDescendants = true PrimaryFrame.BackgroundTransparency = 1 PrimaryFrame.Size = UDim2.fromScale(1, 1) PrimaryFrame.AnchorPoint = Vector2.one*.5 PrimaryFrame.Position = UDim2.fromScale(.5, .5) local Configuration = { framerate = fps; currentInfo = nil; currentFrame = 0; absoluteTotal = 0; currentImage = nil; atFrame = 0; infoNumber = 0; } local function preload(id) local id = id if type(id) == string then id = {id} end game:GetService("ContentProvider"):PreloadAsync(id,function(id,assetfetchstatus) if assetfetchstatus == Enum.AssetFetchStatus.Success then print(`Preloaded {id}.`) else task.spawn(warn,`Preloading of {id} failed.`) end end) end local toLoad = {} for i,v in frames do Configuration.absoluteTotal+=v.Frames toLoad[i] = `rbxassetid://{v.Id}` end preload(toLoad) local Audio = Instance.new("Sound",Main) local CurrentAudioSegment = 1 local Audios = ChosenVideo.audios local AudioSpeeds = ChosenVideo.audioSpeeds local TimePosition = 0 Audio.Volume = 5 Audio.SoundId = "rbxassetid://"..Audios[CurrentAudioSegment] Audio.PlaybackSpeed = (typeof(AudioSpeeds) == "table" and AudioSpeeds[1] or AudioSpeeds) Audio:Play() Audio.Ended:Connect(function() CurrentAudioSegment = (CurrentAudioSegment == #Audios and 1 or CurrentAudioSegment+1) if typeof(audioSpeeds) == "table" then if audioSpeeds[CurrentAudioSegment] then Audio.PlaybackSpeed = AudioSpeeds[CurrentAudioSegment] else Audio.PlaybackSpeed = 1 end elseif typeof(audioSpeeds) == "number" then Audio.PlaybackSpeed = audioSpeeds end Configuration.currentFrame = 0 TimePosition = 0 warn("_Sound has ended. Now heading to the next segment.") Audio.SoundId = "rbxassetid://"..Audios[CurrentAudioSegment] Audio.PlaybackSpeed = (typeof(AudioSpeeds) == "table" and AudioSpeeds[1] or AudioSpeeds) Audio:Play() end) local sync = false local sync1 = false local duration = Configuration.absoluteTotal / Configuration.framerate local r1 = duration / Configuration.absoluteTotal local r2 = r1 * Configuration.currentFrame local tp = r2 * Audio.PlaybackSpeed game:GetService("RunService").Heartbeat:connect(function() if sync == true then sync = false sync1 = true coroutine.wrap(function() Audio.TimePosition = 0 Audio.TimePosition = tp + task.wait() end)() sync1 = false end end) local function create(data) if Configuration.infoNumber + 1 > #frames then Configuration.infoNumber = 0 PrimaryFrame:ClearAllChildren() end pcall(game.Destroy,Configuration.currentImage) Configuration.infoNumber+=1 Configuration.currentInfo = data Configuration.atFrame = 1 local Image = Instance.new("ImageLabel", PrimaryFrame) Image.BackgroundTransparency = 1 Image.Size = UDim2.new(data.Columns, 0, data.Rows, 0) Image.Position = UDim2.new(.5, 0, .5, 0) Image.Image = `rbxassetid://{data.Id}` Configuration.currentImage = Image end create(frames[Configuration.infoNumber]) local currentTimer = 0 local stillRunningTask = false owner.Chatted:Connect(function(v) if v:sub(1,5) == "-sync" then sync = true end end) game:GetService("Players").PlayerAdded:Connect(function(v) v.CharacterAdded:Once(function() sync = true end) end) local gabrgaeeeee = os.clock() game:GetService("RunService").PostSimulation:Connect(function(DeltaTime) --if stillRunningTask then return end --stillRunningTask = true currentTimer+=DeltaTime local framerategarbage = (1/Configuration.framerate) if os.clock() - gabrgaeeeee >= framerategarbage then currentTimer = 0 gabrgaeeeee = os.clock() Configuration.currentFrame+=1 local data = Configuration.currentInfo Configuration.atFrame = (Configuration.atFrame + 1 > data.Frames and create(frames[Configuration.infoNumber]) or Configuration.atFrame+1) local currentRow = 1 local currentColumn = Configuration.atFrame --repeat if currentColumn > data.Columns then currentRow += 1 currentColumn -= data.Columns end -- until not (currentColumn > data.Columns) Configuration.currentImage.Position = UDim2.new(-(currentColumn - 1), 0, -(currentRow - 1), 0) r1 = duration / Configuration.absoluteTotal r2 = r1 * Configuration.currentFrame tp = r2 * Audio.PlaybackSpeed if math.abs(Audio.TimePosition - tp) >= .15 then Audio.TimePosition = tp end end -- stillRunningTask = false end)
Editor Settings
Theme
Key bindings
Full width
Lines