How to use just a portion of a YouTube video

I recently had to find a way to only play a portion of a YouTube video for a colleague where I work. I knew I could add a start time easily that would make the video start at a certain point but was unsure of how to make it stop at a certain point. After a while of looking around the internet I found my answer and it was extremely simple.

To start a YouTube video at a certain point.

To do this get the URL for the video


once you have this put it in the URL bar of your web browser and type


at the end of the URL. This will make the video start playing at ten seconds in.

To Play just a portion of the video.

This is the bit I learnt how to do. Using the code below we can just alter the details needed

<div videoID="XbGs_qK2PQA" startTime="112" endTime="220" height="400" width="400" id="youtube-player"></div>
<script src="http://labnol.googlecode.com/files/youtube-embed.js"></script>

This code is to be used within a webpage to embed the portion of the video.

The VideoID parameter is the video ID this is found in the URL of the video usually starting ?v=


So for the above URL the ID would be XbGs_qK2PQA.

The startTime parameter is the start time and the endTime is obviously the end time.
The time is simple to calculate, for 1 minute 52 seconds it would be (60*1 + 52) = 112.
For a time of 3 minutes 38 seconds you would do (60*3 + 38) = 218.

Once embeded you should be able to play the selection of video on the webpage.


Leave a Reply

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