Not all video websites are compatible with this module, in fact it might be as few as half of the sites out there will work. This module was designed on the basic idea that some video hosts insert a video ID in the url for a video that is often used in the embed code to embed the video. The module figures out the ID from the URL and then uses that ID in the embed code to insert the videos into the popup area.
If you open up /modules/video_plus/video_plus.php you will quickly realize how the code works. Looking at the below example I will analyze how the video ID is grabbed from a youtube URL and then inserted into the youtube embed code.
Step 1
Find a youtube video that you want to post. Analyze that url. See that ending segment with the alphanumeric ID?
Code:
http://www.youtube.com/watch?v=PN2HAroA12w
Lets look at the embed code for that video.
Code:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/PN2HAroA12w&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/PN2HAroA12w&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
Step 3
Open up /modules/video_plus/video_plus.php. Find an existing video host that has a similar url structure and copy/paste it so that you can work from a copy of it to insert your new video host. In this example I will be copy/pasting the Vimeo code since it's pretty close to the youtube url structure (their url ends with and ID)
Code:
// code to display Vimeo WWW
if (preg_match("/http:\/\/www.vimeo.com\/([0-9a-zA-Z\-\_]*)/i", $url, $matches)) {
return '<object width="700" height="415">'.
'<param name="movie" value="http://vimeo.com/'.$matches[1].'" />'.
'<param name="allowfullscreen" value="true" />'.
'<embed src="http://www.vimeo.com/moogaloop.swf?clip_id='.$matches[1].'" quality="best" scale="exactfit" width="700" height="400" type="application/x-shockwave-flash" />'.
'</object>';
}
Code:
if (preg_match("/http:\/\/www.youtube.com\/watch\?v=([0-9a-zA-Z-_]*)/i", $url, $matches)) {
{
([0-9a-zA-Z-_]*) is being used to replace the video ID from the url. If the video ID uses special characters like a forward slash you should use (.*).
As a final step to this line we will be adding (.*) after that video ID code so that if the url has extra information included (like what site pointed to the url) it will not assign that as part of the ID.
Next I will replace the return variable with one to match Youtubes embed structure. I will then change the size to match our 700x400 popup window.
Code:
return '<object width="700" height="400">'.
'<param name="movie" value="http://www.youtube.com/v/'.$matches[1].'" />'.
'<param name="wmode" value="transparent" />'.
'<embed src="http://www.youtube.com/v/'.$matches[1].'&autoplay=0" type="application/x-shockwave-flash" wmode="transparent" width="700" height="400" />'.
'</object>';
Step 4
You should check to see if the video site supports WWW and non-WWW urls. If it supports both you will need to copy/paste the code you just created and add/subtract the WWW so that it will recognize both versions of the site.
















