user3741214
user3741214

Reputation: 61

Load video then run script?

Here's my dilema, and I've searched to no avail.

I have a need to load and play an mp4 video once they page is fully loaded, then once that video is done I'd like to run a script to fade there div container of them video is in out to effectively get rid of it. Think of this as an intro video that plays, then gets removed.

I know this is possible with flash, but I'd prefer not to use flash if possible. Any ideas?

Thanks in advance.

Josh

Upvotes: 0

Views: 830

Answers (1)

mlr
mlr

Reputation: 896

You can use Javascript: take a look at this post

If I have understood correctly what you want to do, you basically need to remove the DOM element containing the video once it ends:

<script>
    var video = document.getElementsByTagName('video')[0];

    video.onended = function(e) {
      var parent = video.parentNode;
      if (parent) {
         parent.removeChild(video);
      }
    };
</script>

Assuming you only have one video TAG in your page (otherwise you can use document.getElementById)

Upvotes: 1

Related Questions