View Full Version : Help with auto video embedding php script

DJ Hands3
10-23-2011, 08:52 PM
1) Project Details:

I have a php script that will take a youtube link from the text in my blog and embed a player instead.

I would like to be able to do this with other video links such as facebook and other popular sites

I have found a good php class to do this but can't implement this into how I need it to work.

My current working script is this:

//youtube embed video

function parseYoutubeUrls($message, $width = -1, $height = -1)
// defaults
if($width == -1) { $width = 425; }
if($height == -1) { $height = round((344/425) * $width); }

// get all urls in text
$regexp = "/<a\s+.*?href=[\"\']?([^\"\' >]*)[\"\']?[^>]*>(.*)<\/a>/i";
if(preg_match_all($regexp, $message, $matches, PREG_SET_ORDER))
// check each url
foreach($matches as $match)
// replace all youtube urls with embedded flash player
$parsedUrl = parse_url($match[1]);
parse_str($parsedUrl["query"], $query);
$videoId = ($query['v']);
$replace = '<div align="center"><p><object width="'.$width.'" height="'.$height.'"><param name="movie" value="http://www.youtube.com/v/'.$videoId.'&hl=sv&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$videoId.'&hl=sv&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$width.'" height="'.$height.'"></embed></object></p></div>';
$message = str_replace($match[0],$replace, $message);
return ($message);

//youtube embed video finish

The class I have found is this: http://www.phpclasses.org/package/7011-PHP-Embed-video-and-images-from-remote-sites.html

and I believe this will work

The working youtube script can be seen here www.djhandsfree.co.uk

My blog is built around this package here: http://mybloggie.mywebland.com/

The only files that need modifying within this package are with the includes folder being files: functions.php and in the parent folder view.php and viewmode.php

Other links I have used so far to help me are:

2) Payment method/ details (Paypal, check? Timeline?):

Payment by Paypal - please quote a price and I will see if it's within my budget


10-24-2011, 06:31 PM
My price is 30$, but I only can get western union payements.
Portfolio: wassgha.t15.org
Email: Wassgha@gmail.com