W
W
webhero2018-05-27 14:35:33
YouTube
webhero, 2018-05-27 14:35:33

How to embed a video from YouTube?

I used

<div class="about-video">
              <video width="400" height="300" controls="controls">
              <source src="https://www.youtube.com/watch?v=jNQXAC9IVRw" type='video/ogg; codecs="theora, vorbis"'>
</div>

but nothing is showing except the control panel

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2018-05-27
@webhero

YouTube does not give a direct video by link (so that it is not downloaded), so you can’t embed it through source, it gives its own embed code.
The "share" button under the video, and there is the "embed" button. And copy the code.
Here's one for your video.

<iframe width="560" height="315" src="https://www.youtube.com/embed/jNQXAC9IVRw" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

F
frees2, 2018-05-27
@frees2

It's better to insert it this way, one player for all videos.

var player;  function onYouTubeIframeAPIReady() 
{ player = new YT.Player('player',{ videoId:'<?php echo''.$fulluri2.'' ; ?>',
playerVars: { autoplay: 1, html5: 1, theme: "light", modesbranding: 0,
color: "white", iv_load_policy: 3, showinfo: 0, controls: 2, 'wmode':'opaque',<?php  echo ''.$list.''; ?>}, }); }  
var tag = document.createElement('script');tag.src = "//www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question