import './video.scss';
import {createElement} from "../../_global/scripts/helpers";

export const createVideo = ({
  videoSrc = 'https://cdn.jsdelivr.net/npm/big-buck-bunny-1080p@0.0.6/video.mp4',
  posterSrc = 'https://source.unsplash.com/T5nXYXCf50I/880x495',
  caption = 'Lorem ipsum dolor sit amet consetetur',
  copyright = '© Marco Mustermann für Mustervideos',
}) => {
  const figure = createElement('figure', ['video']);
  const videoBox = createElement('div', ['video-box'], null, figure);
  const video = createElement('video', [], null, videoBox);
  video.src = videoSrc;
  video.controls = true;
  if (posterSrc && posterSrc.length > 0) {
    video.poster = posterSrc;
  }

  if (copyright && copyright.length > 0) {
    createElement('span', ['copyright'], copyright, videoBox);
  }
  if (caption && caption.length > 0) {
    createElement('figcaption', [], caption, figure);
  }

  return figure;
}