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

210
Views
react-player cant play local video

I'm trying to create a popup that will play a video and when it clicked while playing it will pause and hide the popup.

This is when the user clicks to show and play the video

<div className="mn sr" onClick={() =>  vidControl("PLAY")}>
       Showreel
</div>

It will make this div visible and play the video

import Video from "../assets/videos/showreel/showreel.mov";

<div className="showreel" style={videoOpen ? { display: "block" } : { display: "none" }}>
      <ReactPlayer
        url={Video}
        className="sr-video"
        onClick={() => vidControl("PAUSE")}
      />
</div>

This function act as the video control or so-called

const vidControl = (params) => {
    const video = document
      .querySelector(".showreel")
      .getElementsByTagName("video")[0];
    if (params === "PLAY") {
      video.play();
      setVideoOpen(true);
    } else {
      video.pause();
      setVideoOpen(false);
    }
  };

I have no problem when running it locally, but when I deployed and click to play it, there is an error says.

Uncaught (in promise) DOMException: The element has no supported sources.

I've searched for the same error and tried to fix it with this code since they say I gotta handle the promise but in the end, it doesn't fix my problem.

async function videoPromise() {
    const video = document
      .querySelector(".showreel")
      .getElementsByTagName("video")[0];
    try {
      await video.play();
      setVideoOpen(true);
      console.log("play");
    } catch (err) {
      video.pause();
      setVideoOpen(false);
      console.log(err, "error");
    }
  }

Is there any problem with the code or the logic here? Appreciate any kinda responses, thanks before.

about 4 years ago · Juan Pablo Isaza
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!