   await playOneFrame();
}

let _frameCount = -1;
async function countFrames() {
  if (_frameCount === -1) {
    const video = document.querySelector('video');

    if (!video.duration)
      return 0;

    if (video.currentTime)
      await playToTheEnd();

    let count = 0;
    while (true) {
      ++count;
      await playOneFrame();
      if (video.ended)
        break;
    }
    _frameCount = count;
  }
  return _frameCount;
}

async function seekLastFrame() {
  let frameCount = await countFrames();
 