Embed Part Of YouTube Video – How To’s

youtube WordPress

I have always been wondering how to embed part of YouTube video in case if I just want to share the best part of video and rest are of no use to me and the viewers. Embedding YouTube Videos has been the best way to share the information with others. And if we can share that information by a part of that video then it would just be a waste of time for viewers to see the whole video for that important part.

How to embed part of YouTube video

Embed Part Of YouTube Video

Embed Part Of YouTube Video

  1. Suppose if there is a specific point from where you want the video to start and play it till the end. Then with this trick you can embed part of YouTube video which will play from point specified by you till the end. For this you will need to provide the starting time in the embedding code.You will need to replace VIDEO_ID  by the actual ID of your YouTube video and provide with a start time. If you want the video to start from 3 minute and 24 seconds mark, sick then you’ll specify the time t where t is the value 204s calculated by t=(60*3 + 24). Replace 3 by minute and 24 by second from where you want to start.
  • Original Embed Code

<iframe width=”560″ height=”315″ src=”http://www.youtube.com/embed/MSHePHg8k0o” frameborder=”0″ allowfullscreen></iframe>

  • Code To Embed Part Of YouTube Video (Different Starting Time)

<iframe width=”560” height=”315” frameborder=”0” allowfullscreen src=http://www.youtube.com/embed/MSHePHg8k0o#t=8s></iframe>

2. If you want to embed part of YouTube video with both start and end time according to your choice then you need to provide both the timings in the code and you also need to include a javascript url because standard YouTube embed code does not support the end time parameter.

  • Code to embed a part of YouTube Video with customized start and end time.

<div videoID=”MSHePHg8k0o” startTime=”8″ endTime=”60″ height=”400″ width=”400″ id=”youtube-player”></div>
<script src=”http://labnol.googlecode.com/files/youtube-embed.js”></script>

Replace the Video id with your YouTube Video id and the start and end time according to your choice calculated on the same formula mentioned above. The time actually is in seconds from where you want to start an end the video. And enclose the code in the <div> tag as shown above. You can refer to this annotated source code to know the working of this code.

If you have a very popular site and have lots of traffic then you should host this youtube-embed.js file on your own server to facilitate quick and easy loading of the script and also because

googlecode.com may offer limited bandwidth. When you host this file on your server then replace the url which include the script in your code with the url of the file on your server. To create the youtube-embed.js file visit the annotated source code and copy the script code. Then paste that in a blank text file and click on save as. Then name the file as youtube-embed.js. Don’t forget to mention the .js extension. Then change the parameter below from text file to all files and click on save. After that upload the file to your server and note the url of that file. You will need to url every time you want to embed part of YouTube video.

  • Code to embed part of YouTube video when you host the script file on your server.

<div videoID=”MSHePHg8k0o” startTime=”8″ endTime=”60″ height=”400″ width=”400″ id=”youtube-player”></div>
 <script src=”url of youtube-embed.js”></script>

That’s all you need to do. By this way you can show your users only the important and the required part and rest part can just be ignored. In any case where the viewer wants to view the full video then you don’t need to do anything. Whenever you will embed any video like this, then whenever any viewer will watch that part, he will be provided with the option to watch full video.

This helps you to increase you readership as your viewers will get their information more quickly in comparison of watching the whole video. This is the best way to embed part of YouTube Video and show the users with only required part and save their time.

[source:Labnol]

About Author 

    Find more about me on:
  • facebook

Leave a comment

Your email address will not be published. Required fields are marked *