Triggering a function when an Event Video ends
November 28, 2017
Triggering a function when an Event Video ends
November 28, 2017
Newbie 18 posts
Followers: 44 people

I wanted a ‘next’ button to appear AFTER an event video finished playing.  There might be a way of achieving this with the timeline, but I thought this method worked better.

1. Create a ‘next’ button and ID name it ‘nextBtn’.

2. Hide the button (press the eyeball)

3. Import your event video onto the frame (name does not matter)

4. Execute Javascript on the frame

5. Enter in the following code:

document.getElementsByTagName(“video”)[0].addEventListener(‘ended’,yourFunction,false);

function yourFunction(e) {

cp.show(“nextBtn”);

}

6. Watch and enjoy

Notes

You can add lots of other stuff to this trigger.  I update variables so that the LMS will store and ‘remember’ if a user watched the video or not. I also have a little check mark icon show next to the video.

If you have more than one video on the same frame, you change the array number.  Example – document.getElementsByTagName(“video”)[1]

It depends on which video you load onto the frame first.

Hope this will be helpful to someone.

 

 

All Comments
Sort by:  Most Recent
May 14, 2020
May 14, 2020

Cannot for the life of me get this to work. Using sync video as well. It won’t trigger anything I put in the function for the ended listen event including the following:

document.getElementsByTagName(“video”)[0].addEventListener(‘ended’,yourFunction,false);

function yourFunction(e) {
alert (“Hello”);
}

Like
(1)
Sep 19, 2018
Sep 19, 2018

Hi Jeremy, I have just tried this for my event video, however this doesn’t seem to be working for me. Do I need to change any of the code? And am I executing the javascript on the slide on enter (this is what I have done currently and the button shows instantly rather than when the video has ended) ?

Like
(2)
Jan 13, 2018
Jan 13, 2018

Thank’s for the informations JEREMY SHIMMERMAN

Like
(1)