Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

429
Views
How to play iframe video using JavaScript (not youtube)?

How can I play an video element inside an iframe. The iframe is automatically creating the video element and controls. There are many answers here pointing to add &autoplay to the src address but this is not a youtube iframe.

My HTML code:

<button @click="playVideo(item.name)">play</button>
<iframe :ref="item.name" autoplay :src="item.video_link" :title='item.name'></iframe>

JS

playVideo(itemName) {
     
      this.$refs[itemName] <--- this give me the iframe DOM element I want to play

    },

Rendered HTML:

enter image description here

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

Since you have the source MP4, you should be using <video> instead of an iframe. You'll then have full access to autoplay, controls and other features.

Based on your code, this would look something like:

<video :ref="item.name" autoplay :title='item.name'>
  <source :src="item.video_link" type="video/mp4">
</video>

And since IPFS can be a bit slow for first load, you can also specify poster to show a thumbnail while the content is loading. Here's an example using an IPFS source:

<h3>IPFS Embeded Video Demo</h3>  
          <!-- ๐Ÿ‘‡ required for autoplay in Chrome --> 
<video autoplay muted autopictureinpicture controls poster="https://i.stack.imgur.com/O9qG3.jpg?s=256&g=1" height="200">
  <source src="https://ipfs.io/ipfs/QmbGtJg23skhvFmu9mJiePVByhfzu5rwo74MEkVDYAmF5T" type="video/webm">
</video>

about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!