After having developed shortcodes for SoundCloud and Dailymotion, it is now time to start embedding YouTube Video Player and YouTube Playlists anywhere you want. The shortcode for YouTube player lets you insert the player inside your Posts, Widgets and even the threaded comments with a single line of code. The method is extremely easy and lets you add the responsive version YouTube video Player which adjusts automatically to any screen size. You can now easily share MP4 or HD videos with your readers from YouTube with an extremely easy way. Lets see its demo in action!
Note: If YouTube is banned in your country try viewing the demo by installing this tool.
There are some old techniques which lets you embed YouTube videos in blogger comments but the method we are sharing today gives you an extra benefit. It lets you add a light-weight shortcode which can be inserted almost anywhere not just the comment sections. You can treat it as a simple TEXT which can be pasted on any location of your template structure. It also gives you full control over your player or playlist thanks to the attributes which you can configure to turn ON or OFF the Player options. So it has a lot more to offer than any method shared earlier!
1. Install Blogger Shortcode Plugin
In order to use YouTube shortcode you must first install the shortcode plugin for your blogger blog by following 7 easy steps shared on the link below:
Skip installing it if you have already added it in your blogger template
2. How To create the YouTube Shortcode?
First select a video from Youtube and then copy its Video ID which is a 11 Characters pattern that is added at the end of every YouTube Page URL, as shown below
In our example the Video ID is Qy4yULSqBA0.
Next use the shortcode below to insert your Player anywhere on your blog
[youtube src="Qy4yULSqBA0"/]
Replace the Video ID inside src with yours.
Output:
That simple!
Create a YouTube Playlist Shortcode
This time find your favorite playlist on Youtube and copy the Video ID and Playlist ID from the URL in your address bar as shown below
Then use the shortcode below to embed your playlist on your web blog
[youtube src="-L-GOHa5-YQ" playlist="PL332F98D63FD60CB6"/]
The Video ID is inserted inside "src" and Playlist ID is inserted inside "playlist"
Output:
Customize your Player!
Find below the complete list attributes supported by the shortcode
Attribute | Definition |
---|---|
src | Insert Video ID here |
playlist | Insert Playlist ID here |
width | Adjusts width of video player. Can also be assigned in percentage for responsiveness. |
height | Adjusts height of video player |
info | Setting it to "0" will hide the video title and player actions. By default it is set to "1" |
control | Setting it to "0" will hide the player controls like the play/pause buttons, settings, streamer and Volume options. By default it is set to "1" |
related | Setting it to "1" will show suggested videos when the video finishes. By default it is set to false i.e. "0" |
Use the format below to insert attributes inside shortcode. In the video below I am turning OFF the controls, Video title and turning ON showing related videos when video ends. I am also re-sizing the video using custom width and height.
[youtube src="z2_2cFityc4" control="0" info="0" related="1" width="450" height="350"/]
Output:
Wasn't that easy!
Need Help?
I hope this new shortcode helps you embed videos on your blog with much more ease and comfort. Let us know if you need any help if needed. There is a lot more to come which will change your blogging experience forever. Stay tuned!
Peace and blessings buddies! =d