Video Loop

I need to build a super simple App for our aquarium exhibit space.

Basically we just need the iPad to play back a video full-screen, on a permanent loop, and not respond to any user input.

I have not been able to get the video playback to work. I tried creating a onComplete listener but the movie refuses to play again after the initial playback.

Here is some sample main.lua code:

local function playMyVideo()
media.playVideo( “sample.m4v”, false, playMyVideo )
end

playMyVideo()

This of course causes a stack overflow on the Corona simulator because it does not provide native video feedback but should not be a problem on the Xcode simulator.

Any suggestions on what to do? [import]uid: 6310 topic_id: 15166 reply_id: 315166[/import]

Someone else who was having this issue found that at present you should set a very brief delay using a timer between plays, I believe. :slight_smile: [import]uid: 52491 topic_id: 15166 reply_id: 56145[/import]

Thanks Peach.

I tried it and it is sill not working:

local function executeDelay()
timer.performWithDelay ( 10000, playMyVideo )
end

local function playMyVideo()
media.playVideo( “sample.m4v”, false, executeDelay )
end

playMyVideo()

I’ll keep trying stuff [import]uid: 6310 topic_id: 15166 reply_id: 56177[/import]

Hey there,

I actually just tested this on .591 and it worked perfectly.

I believe the issue may be that you haven’t done your code right, assuming you’ve done what is showing above - you need to use a forward declaration.

Try this;

[lua]local playMyVideo

local function executeDelay (event)
timer.performWithDelay ( 10000, playMyVideo, 1)
end

playMyVideo = function()
media.playVideo( “sample.m4v”, false, executeDelay )
end

playMyVideo()[/lua]

Let me know how that works :slight_smile:

Peach [import]uid: 52491 topic_id: 15166 reply_id: 56247[/import]

Yes! It works. Thanks!

Let me see if I understand what I was doing wrong.

By defining the functions like:

local function1()
callFunction2
end

local function2()
callFunction2
end

callFunction2

LUA does not recognize the call from function1 because it has not yet read the declaration for function 2

by doing this:

local function2

local function1()
callFunction2
end

function2 = function()
callFunction2
end

callFunction2

When LUA reads the declaration for function1 it now knows that function2 is some sort of object even though it is not yet a function?
farther down in the code we populate the function2 variable with a function declaration so it will actually know to behave like a function when called.

Is this right? [import]uid: 6310 topic_id: 15166 reply_id: 56267[/import]

Spot on!

It took me a long time to properly understand forward declarations, but once I did it made things MUCH easier - now I don’t have to shuffle my code around endlessly/needlessly :wink:

Glad to have been of help :slight_smile:

Peach [import]uid: 52491 topic_id: 15166 reply_id: 56362[/import]

Hi Peach!

I have a slightly different scenario. I too want to simply play a full video with an infinite loop. The difference is that I want the user to be able to get back to the main menu in order to choose a different video to play if he or she chooses (that video too will loop). How will the above code you’ve provided differ? I’m using director to get to the different video files if that bit of information is helpful.

Jerry [import]uid: 39859 topic_id: 15166 reply_id: 56796[/import]

Hi Jerry, hope you’ve been well :slight_smile:

You’d have a button which stopped the video then changed scenes in the usual way.

Or is it more complex than that?

Peach [import]uid: 52491 topic_id: 15166 reply_id: 56877[/import]