q5play
    Preparing search index...

    Function createVideo

    • 📑 Creates a video element.

      Note that videos must be muted to autoplay and the play and pause functions can only be run after a user interaction.

      The video element can be hidden and its content can be displayed on the canvas using the image function.

      Parameters

      • src: string

        url of the video

      Returns HTMLVideoElement & PromiseLike<HTMLVideoElement>

      a new video element

      await Canvas(1);

      let vid = createVideo('/assets/apollo4.mp4');
      vid.size(200, 150);
      vid.autoplay = vid.muted = vid.loop = true;
      vid.controls = true;
      await Canvas(200, 150);
      let vid = createVideo('/assets/apollo4.mp4');
      vid.hide();

      q5.mousePressed = function () {
      vid.currentTime = 0;
      vid.play();
      };
      q5.draw = function () {
      rotate(mouseX / 55);
      image(vid, -100, -75, 200, 150);
      };