Converting videos to different formats can be difficult and time-consuming.
An easier solution is to let YouTube play the videos in your web page.
Different versions of different browsers support different video formats.
Earlier in this tutorial, you have seen that you might have to convert your videos to different video formats to make them play in all browsers.
Converting videos to different format can be difficult and time consuming.
An easier solution might be to let YouTube play the videos in your web page.
YouTube will display an id (like tgbNymZ7vqY), when you save (or play) a video.
You can use this id, and refer to your video in the HTML code.
https://www.youtube.com/watch?v=MJ49xD7yXT4
<iframe width="400" height="230" src="https://www.youtube.com/embed/lJIrF4YjHfQ" title="Embed videos and playlists" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
To play your video on a web page, do the following:
<iframe>
element in your web pagesrc
attribute point to the video URLwidth
and height
attributes to specify the dimension of the player <iframe width="420" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY">
</iframe>
You can let your video start playing automatically when a user visits the page, by adding autoplay=1
to the YouTube URL. However, automatically starting a video is annoying for your visitors!
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1">
</iframe>
</body>
</html>
Add mute=1
to let your video start playing automatically (but muted).
Example:
HTML
<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY?mute=1">
</iframe>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY?mute=1">
</iframe>
</body>
</html>
You can let your video start playing automatically when a user visits the page, by adding autoplay=1
to the YouTube URL. However, automatically starting a video is annoying for your visitors!
Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.
Add mute=1
after autoplay=1
to let your video start playing automatically (but muted).
Example:
HTML
<iframe width="420" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1&mute=1">
</iframe>
A comma separated list of videos to play (in addition to the original URL).
For more Understanding: Youtube Developer
Example:
HTML
<iframe id="ytplayer" type="text/html" width="100%" height="405"
src="https://www.youtube.com/embed/?listType=playlist&list=PL590L5WQmH8eYTXiTTjzo4YnK7vkCqZTI"
frameborder="0" allowfullscreen>
Add loop=1
to let your video loop forever.
Value 0 (default): The video will play only once.
Value 1: The video will loop (forever).
LoopTube is a free online tool to repeat any YouTube videos. Just select YouTube videos by typing a URL in the search bar, and you can set AB loop in any point of the video. This is useful when you want to learn some kind of skills (such as languages, sports, music, etc.) by watching a specific part over and over.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY?playlist=tgbNymZ7vqY&loop=1">
</iframe>
</body>
</html>
Add controls=0
to not display controls in the video player.
Value 0: Player controls does not display.
Value 1 (default): Player controls display.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY?controls=0">
</iframe>
</body>
</html>
With keyboard shortcuts, save time navigating YouTube.
To access the list of Keyboard shortcuts, go to your profile picture , and select Keyboard Shortcuts . You can also enter SHIFT+? on your keyboard. When you mouse over certain player buttons, you’ll see the relevant keyboard shortcut. For example, when you mouse over the full screen icon, you'll see 'Full screen (f),' indicating you can enter f to open full screen.
Subscribe to the YouTube Viewers channel for the latest news, updates, and tips.
If you're using the new computer experience, you must click the video player before using keyboard shortcuts. To return to the classic computer experience, go to the profile picture and click Restore old YouTube.
Keyboard shortcut | Function |
Spacebar | Play/Pause when the seek bar is selected. Activate a button if a button has focus. |
Play/Pause Media Key on keyboards | Play / Pause. |
k | Pause/Play in player. |
m | Mute/unmute the video. |
Stop Media Key on keyboards | Stop. |
Next Track Media Key on keyboards | Moves to the next track in a playlist. |
Left/Right arrow on the seek bar | Seek backward/forward 5 seconds. |
j | Seek backward 10 seconds in player. |
l | Seek forward 10 seconds in player. |
. | While the video is paused, skip to the next frame. |
, | While the video is paused, go back to the previous frame. |
> | Speed up the video playback rate. |
< | Slow down the video playback rate. |
Home/End on the seek bar | Seek to the beginning/last seconds of the video. |
Up/Down arrow on the seek bar | Increase/Decrease volume 5%. |
Numbers 1 to 9 | Seek to the 10% to 90% of the video. |
Number 0 | Seek to the beginning of the video. |
/ | Go to search box. |
f | Activate full screen. If full screen mode is enabled, activate F again or press escape to exit full screen mode. |
c | Activate closed captions and subtitles if available. To hide captions and subtitles, activate C again. |
Shift+N | Move to the next video (If you're using a playlist, will go to the next video of the playlist. If not using a playlist, it will move to the next YouTube suggested video). |
Shift+P | Move to the previous video. Note that this shortcut only works when you're using a playlist. |
i | Open the Miniplayer. |