What is the most efficient method for embedding a YouTube video into a <video> tag using React?

I tried embedding a YouTube video using an HTML5 tag, but encountered an error

<div className={classes.VideoContainer}>
    <video
      className={classes.movieInfo__trailer}
      src="https://www.youtube.com/watch?v=V3hy2aLQFrI"
      type="video/mp4"
      autoPlay
      controls
    ></video>
  </div>

Unfortunately, I received an error stating "No video with supported format and MIME type found"

Answer №1

Consider using an iframe in place of the video tag

Change this:

   <div className={classes.VideoContainer}>
        <video
          className={classes.movieInfo__trailer}
          src="https://www.youtube.com/watch?v=V3hy2aLQFrI"
          type="video/mp4"
          autoPlay
          controls
        ></video>
      </div>

To this:

  <div className={classes.VideoContainer}>
       <iframe
          width="560"
          height="400"
          className={classes.movieInfo__trailer}
          src="https://www.youtube.com/watch?v=V3hy2aLQFrI"
          type="video/mp4"
          autoPlay
          controls
        ></iframe>
      </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Save your React JSX components by exporting them in your index.js files

Is there a method to consolidate react-components, specified in jsx-files, into an index.js file? This should allow for the components to be imported using import module from "/module"; let C = module.Component;. Here is an example structure: /module ...

Optimal methods for organizing various perspectives on a one-page website

I am developing an application that incorporates AngularJS and Bootstrap. The current setup involves organizing various views using ng-show, allowing for view changes based on button interactions and the enablement/disabling of ng-show values. Within a si ...

Envelop the phrases onto a fresh line

I'm having trouble getting the text inside a div to display correctly. When the text is too long, it just keeps stretching instead of breaking into new lines. How can I make sure that the content displays as a block within the div? Thank you. .box ...

How can I alter the icon's color?

Is it possible for the icon's color to change to red when the condition is greater than 0, and to gray when the condition is equal to zero? <TouchableOpacity onPress={() => { if (Object.values(selectedIt ...

The functionality of Next.js dynamic routes is compromised once deployed

I recently completed a website using Next.js with the following folder structure: pages |- [path] | |- index.js | |- [for-students] | |- [path] | | |- index.js | | index.js | events.js During development, everything functioned smoothly. I utilized ...

What is the best way to turn off default CSS styling in KendoUI?

I am facing an issue in my application where I am using global CSS definitions for "INPUT", "SELECT", and other elements. The problem arises when I try to incorporate KendoUI widgets, as they override my default CSS styles. For instance, my CSS code looks ...

The background-image in Material-UI card does not seem to recognize the props

Is there a way to pass the state.logoClassName from BigBoard to the image className in smallSquare.js? I'm encountering an issue where the logo is displayed when a specific "string" is written in the className (smallSquare.js), but not when {props.log ...

Tips for locating and clicking the 'Start' button in HTML using either find_element_by_xpath or the Selenium-Python API

Need help selecting the 'Start' button and clicking it in the HTML code below. I want to do this using the python-selenium library like so: driver.find_element_by_xpath('//div[contains(@class,"box enter")' ...

Prevent clicking through slides on React by disabling the Swiper feature

Is there a way to handle the global document click event (using React hook useClickAway) so that it still fires even when clicking on a slide? For example, think of a circle in the header like an avatar dropdown - when you click on it, a menu pops up. Th ...

The npx create-react-app command fails to create a React app

Attempting to generate a new React application using the command npx create-react-app myapp on my computer is proving unsuccessful. Here's what I encountered: When running the command D:\AED>npx create-react-app aed, it took 52.503 seconds to in ...

When returning to the homepage from a different route, React Components will re-render and trigger a new API call

Is there a specific reason causing the re-rendering of this component? As far as I know, React preserves the previous page when navigating to another page using the LINK tag. Visit the live link: Thethirdfront.vercel.app www.github.com/saurabhje/Truly-Tru ...

I am looking to conceal an element as soon as a list item is scrolled into view and becomes active

Is it possible to hide a specific element when the contact section is activated on scroll, and have it visible otherwise? How can this be achieved using Jquery? <ul class="nav navbar-nav navbar-right navmenu"> <li data-menuanchor="ho ...

Resource for building user interface components in Javascript

I need assistance with implementing a feature that involves scrolling through different text blocks and corresponding images. Users should be able to select a specific text block and have the associated image on the right scroll into view, similar to a car ...

"Styling a play button on top of an image using CSS

Can someone please assist me in properly displaying a play button over a thumbnail using CSS in my WordPress site? I have tried various methods without success. Any guidance on where I may be going wrong would be greatly appreciated. .post-thumbnail-sid ...

What is the best way to display a placeholder instead of the state's value when a page loads?

I'm having trouble displaying the placeholder of an input instead of its state value. When the page loads, it shows an empty select box because the testType state is null initially. How can I make sure that only the placeholder is shown instead of the ...

Failure occurred in sending POST request from React app to the Rocket backend causing an error

I am currently developing a web application using Rocket for the backend and React for the frontend. Below is the code snippet for the login page: #[post("/login", data = "<data>")] pub fn login( conn: DbConn, mut cookies: Cookies<'_ ...

Setting a default value within an input tag: A step-by-step guide

const [userData, setUserData] = useState([]); const handleUserInfo = (id) => { fetch(`https://602e7c2c4410730017c50b9d.mockapi.io/users/${id}`) .then(res => res.json()) .then(data => setUserData(data)) } <inpu ...

Eliminate the dark backdrop from html5 videos that only shows up for a brief moment

Is there a way to remove the brief black background that appears when loading an HTML5 video? I have tried using CSS without success. The HTML: <div id="start-screen"> <video id="video-element"> <source src="video-mp4.mp4" type="vide ...

Aligning a div vertically in the center of its parent container

I am trying to vertically align a child element within its parent element <!DOCTYPE html> <html> <head> <title>Test</title> <style type="text/css"> #body { font-family: sans-serif, arial, 'Roboto'; } #outer ...

The absence of the Ionic modalController in the React package has been noted

While working with the react and ionic package, I attempted to import modalController from '@ionic/react'. However, an error occurred: Error: When importing '@ionic/react', 'modalController' does not have a default export.. ...