What are the Video Events?

okay. Here I create my listener first.

        local function videoViewListener (event)

            if (event.phase=“ended”) then     --this doesn’t work

                videoView:pause

                videoView:removeSelf()

                videoView=nil

                (code to do something else)

        end

        videoView = native.newVideo( 0,0, V.W, V.H)
        videoView:load( “test.m4v” )  –     Loads the specified video.
        videoView:play()

I then setup a listener.

        videoView:addEventListener (“video”,videoViewListener)

The listener doesn’t work and I can’t find a list of event.phase values for “video”. I only found another topic on the same subject, but the poster solved his own problem by creating a timer that would run the ‘close’ after a certain number of seconds - perhaps that’s a good fix for him to continue developing, but I would like to know what events that Corona supports for native video. And is it different for each platform? I can’t find any tutorial or answers online that provide sufficient answers so that I can, for example, create my own play, rewind, and fast-forward buttons using the :seek comment - why? Because I don’t know what “event” to capture to know where the play head is either. Please help.

I would actually like to know that too - did you ever fint the answer? :slight_smile:

Hi @k1010110,

This is an oversight on our part (lack of documentation for video events). I’ll add these soon. In the meantime, you can try doing a pairs() output on the event table to see what’s inside it:

[lua]

local function videoViewListener( event )

    for k,v in pairs(event) do

        print( k,v )

    end

end

[/lua]

Hope this helps,

Brent

As a note, you are using “=” in an if statement up there. It should be “if ( event.phase == “ended” ) then”

You can also use the Json module to dump some debug information about a Lua table. Try using json.prettify if you want a deeper look than the pairs method.

Thank you very much, for answering a relatively old thread ;). Ill try that as soon I get the chance!

Hi @k1010110,

The video events are now documented here:

https://docs.coronalabs.com/api/event/video/index.html

Best regards,

Brent

I would actually like to know that too - did you ever fint the answer? :slight_smile:

Hi @k1010110,

This is an oversight on our part (lack of documentation for video events). I’ll add these soon. In the meantime, you can try doing a pairs() output on the event table to see what’s inside it:

[lua]

local function videoViewListener( event )

    for k,v in pairs(event) do

        print( k,v )

    end

end

[/lua]

Hope this helps,

Brent

As a note, you are using “=” in an if statement up there. It should be “if ( event.phase == “ended” ) then”

You can also use the Json module to dump some debug information about a Lua table. Try using json.prettify if you want a deeper look than the pairs method.

Thank you very much, for answering a relatively old thread ;). Ill try that as soon I get the chance!

Hi @k1010110,

The video events are now documented here:

https://docs.coronalabs.com/api/event/video/index.html

Best regards,

Brent