R
R
rinatoptimus2015-04-28 01:12:48
JavaScript
rinatoptimus, 2015-04-28 01:12:48

How to pause video playback?

On the page of the site from the autoplay folder, a video is played. How to make it pause itself at a certain point in time, say, at the fifth second? At the same time, a black screen should not appear in its place.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petrov, 2015-04-28
@Petroveg

How to implement video/audio playback on button click?

$(function (e) {
  $('[data-type="video"]').on('play', function () {
    var video = this;

    setTimeout(function () {
      video.pause();
    }, 5000);
  });
});

$('[data-type="video"]').on('timeupdate', function () {
  if (this.currentTime > 5) {
    this.pause();
  }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question