0

I'm so sorry, but I can't get a youtube video to play (https://www.youtube.com/watch?v=SyRv0-oPfKE) inside a video tag. I know about the iframe API but in this case it has to have the default html5 controls, not the youtube controls. I probably missed something stupid but can't figure it out...

Anyone know how to do this?

EDIT:

so I tried:

<video
          controls='controls' 

          src={`http://www.youtube.com/get_video_info?&video_id=${id}&asv=3&el=detailpage&hl=en_US`}
          type='video/mp4'
        />

and tried:

<video
  controls='controls' 

  src={`https://www.youtube.com/watch?v=SyRv0-oPfKE&html5=1`}
  type='video/mp4'
/>

but I get blank page.

Woah
  • 9
  • 4

1 Answers1

0

The HTML video element expects video files as a source. If you want to play a YouTube video using the native HTML video player, you'll have to provide a link to the video itself, not to the YouTube website for this video.

Also keep in mind, that not all browsers can handle any video formats. See MDN: Media formats for HTML audio and video.

feeela
  • 29,399
  • 7
  • 59
  • 71
  • updated my question, did you mean something like that? – Woah Apr 25 '18 at 09:59
  • 1
    No. `https://www.youtube.com/watch?v=SyRv0-oPfKE&html5=1` is the URL to an HTML document. – Quentin Apr 25 '18 at 10:00
  • @Cetico The URL to a YouTube video can also be resolved from the page link: replace `/watch?v=VIDEO_HASH` with `/v/VIDEO_HASH`. Please read the information linked above for an understanding of what you are doing right or wrong. – feeela Apr 25 '18 at 10:04
  • I'm sorry but i failed, I tried replacing v=VIDEO_HASH, I read the answer. I understand that the video src input is asking for an mp4 file instead of a HTML page. So the only way to do it is through some shady mp4link API? – Woah Apr 25 '18 at 10:55
  • @Cetico If you really want to go your own way, instead of using the YouTube iframe-option: Yes – feeela Apr 25 '18 at 11:03