Friday, April 15, 2022

[FIXED] How to autoplay local video with iframe?

Issue

There are many solutions out there on how to make youtube/vimeo autoplay a video but they don't seem to work on a local video:

<template>
  <section id="vision" class="vision">
    <iframe src="videos/cgi_neutral.mp4?autoplay=1" allow="autoplay" allowfullscreen="true"></iframe>
  </section>
</template>

This does not autoplay.


Solution

First, instead of using an iframe, use a <video> tag. (Because its self-hosted on your website, no need to use an iframe) To make it autoplay, just add the "autoplay" attribute.

For Example:

<video width="320" height="240" controls autoplay>
 <source src="movie.mp4" type="video/mp4">
</video>


Answered By - Marcus
Answer Checked By - Timothy Miller (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.