Page 1 of 2
[Solved] Help with looping video.
Posted: Mon Mar 28, 2016 7:52 am
by Nicholas Scott
//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?
Code: Select all
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\\
Re: Help with looping video.
Posted: Mon Mar 28, 2016 11:32 am
by Bunnybacon
The error is in your testForBackgroundImage() function. You are ending it too soon.
Code: Select all
local function testForBackgroundImage()
if backgroundImage:isPlaying() then
backgroundImage:rewind()
backgroundImage:play()
end
end
Re: Help with looping video.
Posted: Mon Mar 28, 2016 11:33 pm
by Nicholas Scott
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.
Re: Help with looping video.
Posted: Tue Mar 29, 2016 12:03 am
by slime
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.
Re: Help with looping video.
Posted: Tue Mar 29, 2016 12:05 am
by Nicholas Scott
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
Re: Help with looping video.
Posted: Tue Mar 29, 2016 10:09 am
by bobismijnnaam
I can reproduce this. Code:
Code: Select all
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
OGV file:
https://commons.wikimedia.org/wiki/File ... xample.ogv (Just click the download link above and then use wget or something to get the file)
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.
Re: Help with looping video.
Posted: Tue Mar 29, 2016 11:24 am
by pgimeno
Same here. Ctrl+\ works though, which means SIGQUIT is not ignored.
Re: Help with looping video.
Posted: Tue Mar 29, 2016 6:50 pm
by bobismijnnaam
So do we reopen the ticket on bitbucket or are we missing something? The code seems so dead simple it can't be wrong
Re: Help with looping video.
Posted: Tue Mar 29, 2016 8:43 pm
by bartbes
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.
Re: Help with looping video.
Posted: Tue Mar 29, 2016 10:02 pm
by pgimeno
Yes, current tip fixed it for me. Let's hope the OP's problem was the same issue.