-- Play Video Sample function love.load() scrw = love.graphics.getWidth() scrh = love.graphics.getHeight() -- load video(.ogv) video = love.graphics.newVideo("bg.ogv") -- video:play() -- video:pause() videostep = 0 -- init sprite player = {} player.img = love.graphics.newImage("enemy11_96x96.png") player.x = scrw / 2 player.y = scrh / 2 player.spd = scrw / 3 player.update = function(self, dt) if love.keyboard.isDown("left") then self.x = self.x - self.spd * dt elseif love.keyboard.isDown("right") then self.x = self.x + self.spd * dt end if love.keyboard.isDown("up") then self.y = self.y - self.spd * dt elseif love.keyboard.isDown("down") then self.y = self.y + self.spd * dt end end player.draw = function(self) local ox = self.img:getWidth() / 2 local oy = self.img:getHeight() / 2 love.graphics.setColor(1,1,1,1) love.graphics.draw(self.img, self.x - ox, self.y - oy) end end function love.update(dt) if videostep == 1 then -- play video video:play() videostep = 2 elseif videostep == 2 then if not video:isPlaying() then -- loop play video:rewind() video:play() end end player:update(dt) end function love.draw() -- canvas clear love.graphics.clear(0, 0, 0, 1) -- draw video love.graphics.setColor(1, 1, 1, 1) love.graphics.draw(video, 0, 0) -- draw sprite player:draw() -- draw text love.graphics.setColor(1, 1, 1, 1) love.graphics.print("ESC to exit.", 8, 4) love.graphics.print("P : movie play", 8, 20) end function love.keypressed(key, scancode, isrepeat) if key == "escape" then love.event.quit() elseif key == "p" then if videostep == 0 then videostep = 1 end end end