Friday, 25 December 2015

How to embed a Youtube video and set where to start the video from and where to stop

In this post I will show you how you can embed a YouTube video and set the video where it should start and where it should stop.

First let's look at the code:

<object width="640" height="385">
<param name="movie" value="https://www.youtube.com/v/FB1cCoib7xQ&hl=en_US&start=143&end=180"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="https://www.youtube.com/v/FB1cCoib7xQ&hl=en_US&start=143&end=180" type="application/x-shockwave-flash" allowscriptaccess="always" width="640" height="385"></embed></object>

As you can see yellow and green highlighted places. These are the places where you need to make a change. For example:  start=143 the numbers you see after = is actually numbers of seconds, so that means you telling the player that it should start playing the video after 143 seconds.

The end=180 means you telling the player to stop after 180 seconds.

FB1cCoib7xQ This is the video ID, you can copy any video ID from YouTube and paste in the green highlighted place and it will play that video.   

Note:
Remember both start and end numbers should be the same (I mean if the first start number is 60 than the second start number should be 60 too).

How to make it play automatically?
By putting &autoplay=1 after the end code you can make it play automatically.

<object width="640" height="385">
<param name="movie" value="https://www.youtube.com/v/FB1cCoib7xQ&hl=en_US&start=143&end=180&autoplay=1"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="https://www.youtube.com/v/FB1cCoib7xQ&hl=en_US&start=143&end=180&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" width="640" height="385"></embed></object>

No comments:

Post a Comment