video.html 608 B

12345678910111213
  1. {{ $src := .Get "src" }}
  2. {{ $type := .Get "type" }}
  3. {{/*
  4. A page can have multiple videos. We need to generate unique id for them.
  5. Here, we are generating a sequence from 1 to 200 and taking the first element after a shuffle.
  6. This will give a random number in most cases. However, if the page has many videos, we might have a collision.
  7. We should find a better approach for doing this.
  8. */}}
  9. {{ $randNumber := index (seq 200 | shuffle) 0 }}
  10. <video class="video-player" id="video-{{ $randNumber }}" playsinline controls>
  11. <source src="{{ $src }}" type="{{ $type | default "video/mp4" }}" />
  12. </video>