[Solved] Help with looping video.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Nicholas Scott
Prole
Posts: 49
Joined: Sun Jun 07, 2015 9:12 am

[Solved] Help with looping video.

Post by Nicholas Scott » Mon Mar 28, 2016 7:52 am

//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\\
Last edited by Nicholas Scott on Wed Mar 30, 2016 12:50 am, edited 3 times in total.

User avatar
Bunnybacon
Prole
Posts: 18
Joined: Fri Mar 25, 2016 8:42 am

Re: Help with looping video.

Post by Bunnybacon » Mon Mar 28, 2016 11:32 am

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

Nicholas Scott
Prole
Posts: 49
Joined: Sun Jun 07, 2015 9:12 am

Re: Help with looping video.

Post by Nicholas Scott » Mon Mar 28, 2016 11:33 pm

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.

User avatar
slime
Solid Snayke
Posts: 2899
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Help with looping video.

Post by slime » Tue Mar 29, 2016 12:03 am

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.

Nicholas Scott
Prole
Posts: 49
Joined: Sun Jun 07, 2015 9:12 am

Re: Help with looping video.

Post by Nicholas Scott » Tue Mar 29, 2016 12:05 am

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

User avatar
bobismijnnaam
Prole
Posts: 18
Joined: Thu Mar 17, 2016 5:18 pm
Location: Netherlands
Contact:

Re: Help with looping video.

Post by bobismijnnaam » Tue Mar 29, 2016 10:09 am

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.
taart
lc = love.timer -- love.chrono :-)

User avatar
pgimeno
Party member
Posts: 2310
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help with looping video.

Post by pgimeno » Tue Mar 29, 2016 11:24 am

Same here. Ctrl+\ works though, which means SIGQUIT is not ignored.

User avatar
bobismijnnaam
Prole
Posts: 18
Joined: Thu Mar 17, 2016 5:18 pm
Location: Netherlands
Contact:

Re: Help with looping video.

Post by bobismijnnaam » Tue Mar 29, 2016 6:50 pm

So do we reopen the ticket on bitbucket or are we missing something? The code seems so dead simple it can't be wrong
taart
lc = love.timer -- love.chrono :-)

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Help with looping video.

Post by bartbes » Tue Mar 29, 2016 8:43 pm

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.

User avatar
pgimeno
Party member
Posts: 2310
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help with looping video.

Post by pgimeno » Tue Mar 29, 2016 10:02 pm

Yes, current tip fixed it for me. Let's hope the OP's problem was the same issue.

Post Reply

Who is online

Users browsing this forum: MrFariator and 26 guests