assert(love.filesystem.isDirectory("samples"),
"Sample directory does not exist.\n"..
"Consider running `./tools/gen_sample.sh`?")
LoveVideo = require("LoveVideo.lovevideo")
LoveVideo.thread_file = "LoveVideo/lovevideo_loadthread.lua"
samples = love.filesystem.getDirectoryItems("samples")
function next_sample()
sample_target_index = sample_target_index
and sample_target_index + 1
or 1
if sample_target_index > #samples then
sample_target_index = 1
end
sample_target = samples[sample_target_index]
bunny = LoveVideo.newVideo("samples/"..sample_target)
end
function love.load()
next_sample()
end
function love.draw()
love.graphics.print(love.timer.getFPS().."fps "..
" - ["..sample_target_index.."]"..sample_target.."\n"..
"N[ext] (un-)[P]ause")
bunny:draw(32,32,
(love.graphics.getWidth()-64)/bunny:getWidth(), (love.graphics.getHeight()-64)/bunny:getHeight() )
end
function love.update(dt)
bunny:update(dt) if bunny:isDone() then bunny = LoveVideo.newVideo("samples/"..sample_target)
end
end
function love.keypressed(key)
if key == "n" then
bunny:stop() next_sample()
elseif key == "p" then
if bunny:isPlaying() then bunny:pause() else
bunny:resume() end
end
end