Hi Frendz,
I need a solution to stop an embed youtube video at a particular timestamp. Any possible way to do this?

Member Avatar for diafol

Get the embed code from spliced. Here's an example:

<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/bYHq5QffAbo&start=10&end=20"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/bYHq5QffAbo&start=10&end=20" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>

You need to get the long link from youtube (embed option, then options)
Paste this into spliced, set the start and stop times, scroll down to get the object embed code. You can get rid of the spliced div though.

All it does is add start and end parameters to the v link.

If you have a db table for videos:

videotype_id (e.g. 1=youtube, 2=vimeo...)
videocode (e.g. bYHq5QffAbo)
videostart (e.g. 10)
videoend (e.g. 20)
videotitle (...)
videocaption (...)

videotype_label (e.g. YouTube)
videotype_template (see below)

A videotype_template for YouTube could be:

<object width="%width" height="%height"><param name="movie" value="http://www.youtube.com/v/%code%start%end"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/%code%start%end" type="application/x-shockwave-flash" allowfullscreen="true" width="%width" height="$height"></embed></object>

You then just substitute placeholders for data from the videos table and default parameters like width and height:

$width = 345;
$height = 200;

$r = mysql_query("SELECT v.*, vt.* FROM videos AS v INNER JOIN vt ON v.videotype_id = vt.videotype_id WHERE v.vid_id = 5");
  $d = mysql_fetch_array($r);

  $temp = $d['videotype_template']; 
  $temp = str_replace('%width',$width,$temp);
  $temp = str_replace('%height',$height,$temp);
  $temp = str_replace('%code',$d['videocode'],$temp);
  $temp = str_replace('%start','&start='.$d['videostart'],$temp);  
  $temp = str_replace('%end','&end='.$d['videoend'],$temp);  

echo "<h3>{$d['videotitle']}</h3>$temp<p>{$d['videocaption']}</p>";

That's off the top of my head. Last bit is a bit naff, but you get the idea.


Check the values of end - perhaps replace the whole end placeholder with "" if no end specified (or = 0)

Thanks for your valuable suggestion Ardav, I get the embed code from splicd as follows

<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/EXLIj0n2BV4&start=70&end=75"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/EXLIj0n2BV4&start=70&end=75" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>							
        <div style="text-align: right; margin-top: 3px; width: 425px; height: 344px;"><a href="http://splicd.com" style="color: rgb(85, 85, 85); font-size: 13px; text-decoration: none; font-family: Helvetica,sans-serif;">powered by <span style="color: rgb(200, 91, 0);">Splicd.com</span></a></div>

But in that the start point is working fine and the end point of video is not. The video is starting from the point where I specified but it continuously running till the end of the video.

The embed source that you specified in the last post did the same....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.