//PROBLEM SOLVED\\
I'm not sure if this is the best method it's just what I tried and it's not working, anybody have any ideas as to why it's not working or another way of looping a video?
backgroundImage = love.graphics.newVideo("gfx/MainMenu.ogv")
local function testForBackgroundImage()
if backgroundImage:isPlaying() then return end
backgroundImage:rewind()
backgroundImage:play()
end
love.update(dt)
testForBackgroundImage()
end
love.draw()
love.graphics.draw(backgroundImage, 0, 0)
end
EDIT: It's sort of working now, it repeats about 3 or 4 times then stops??
EDIT: New build in http://love2d.org/builds/ has fixed the problem! Thanks very much everyone and bartbes! //PROBLEM SOLVED\\
Last edited by Nicholas Scott on Wed Mar 30, 2016 12:50 am, edited 3 times in total.
Bunnybacon wrote:The error is in your testForBackgroundImage() function. You are ending it too soon.
No offense, but that makes little sense and is a bit counter intuitive don't you think? I only want to rewind and play the video ONCE it has ended, if Video:isPlaying() is true then I want to end the function cause I don't want to rewind it and play it while it's still playing.
slime wrote:Which LÖVE version are you using? 0.10.0 had a few bugs with video playback state which were fixed in 0.10.1.
I'm using the latest version, and it still wasn't working and I found that out from some threads so I downloaded it all again and still the problem persists.
EDIT: I'm going to debug the isPlaying() value to see if it is even changing, I'm not sure that it is..
EDIT2: I've debugged it and it plays once, then jumps to false then back to true in the same update and replays, does that about 2 times then it just switches to false and video:rewind() and play() seem to not work any longer?!? Raises more questions than it answers
function love.load()
backgroundImage = love.graphics.newVideo("Typing_example.ogv")
end
function testForBackgroundImage()
if backgroundImage:isPlaying() then return end
backgroundImage:rewind()
backgroundImage:play()
end
function love.update(dt)
testForBackgroundImage()
end
function love.draw()
love.graphics.draw(backgroundImage, 0, 0)
end
The code seems correct to me: if the file is playing just draw it, and if it's not playing rewind it and start playing it. For me it just runs once and then the image freezes at the end. Also, when I close the window, the window closes just fine but the process stays open. I had to pkill -9 it to close the process. I'm running Ubuntu 15.10 with love 0.10.1.
Turns out, the bug wasn't rewinding (for once), it was the end-of-stream detection. This particular video has an audio frame past the end of the video stream, which triggered the bug. I've now fixed it.