• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

[Add More Video Sites] BB Code Media

Your help is amazing and greatly appreciated.
I did everything as instructed and when I added , all I get is a black block.
See here

I can see in the page source that the media key and preview image aren't making it through.

It's this video, right?

http://mitworld.mit.edu/video/870

It works for me on my forum. To add the video you can just paste the URL into your post and rely on auto media embed. Or use the media shortcut in the editor. Either approach should result in this code being inserted into your post:

[media=mitworld]mitw-01375-school-of-sci-simons-math-09dec2010|mitwstill01375schoolofscisimonsmath09dec2010.jpg[/media]
 
I can see in the page source that the media key and preview image aren't making it through.

It's this video, right?

http://mitworld.mit.edu/video/870

It works for me on my forum. To add the video you can just paste the URL into your post and rely on auto media embed. Or use the media shortcut in the editor. Either approach should result in this code being inserted into your post:

[media=mitworld]mitw-01375-school-of-sci-simons-math-09dec2010|mitwstill01375schoolofscisimonsmath09dec2010.jpg[/media]
Ah, I did use the plain bbcode in my previous post so you didn't see what I used.

I use this [media=mitworld]870[/media] with 870 being the video id. But seeing your post, I looks like I did it the wrong way and didn't know what string I have to insert into the media tag.

Now I just copy [media=mitworld]mitw-01375-school-of-sci-simons-math-09dec2010|mitwstill01375schoolofscisimonsmath09dec2010.jpg[/media] and it works beautifully.

Can you explain the correct way to paste url and use media shortcut?
EDIT: I see what you mean by paste the URL (btw, the visual editor will add the url tag and it will not work. I have to do it from the plain editor).
 
I use this [media=mitworld]870[/media] with 870 being the video id.

I could actually move the page scraping into the HTML callback if you want to use that format.

Can you explain the correct way to paste url and use media shortcut?

You can't manually type the BB code because you have to scrape the HTML for the keys. Use the editor shortcut or paste the plain text URL and rely on auto embed. Like I said, I can move around the code if you want to be able to type the BB code with the video number instead.

EDIT: I see what you mean by paste the URL (btw, the visual editor will add the url tag and it will not work. I have to do it from the plain editor).

I think this is your problem:

http://xenforo.com/community/threads/auto-embed-copy-paste-problem.19638/#post-254281
 
I would like to either use that ID and the media code or post the url directly (in the plain editor).

Here is an updated version of the MIT media site. There is no longer a URL Match Callback, and the PHP code has changed:

Admin CP -> Home -> BB Code Media Sites -> Add BB Code Media Site

Media Site ID: mitworld

Site Title: MIT World

Site URL: http://mitworld.mit.edu/

Match URLs: http://mitworld.mit.edu/video/{$id}

Embed HTML:

Code:
<see html callback>

Then under Advanced Options:

Embed HTML Callback: MediaSites_MITWorld::buildEmbed

And you need to create the following directory/file (also attached to this post):

library/MediaSites/MITWorld.php

Code:
<?php

class MediaSites_MITWorld
{
	public static function buildEmbed($mediaKey, array $site)
	{
		// CAPTURE WEB PAGE
		$pageHtml = file_get_contents('http://mitworld.mit.edu/video/' . $mediaKey);

		// ISOLATE THE EMBED CODE FROM THE PAGE SOURCE
		if(preg_match("/[^\w]shareCode:'(?P<embedhtml>[^']+)'/siU", $pageHtml, $match))
		{
			// FROM EMBED CODE, ISOLATE THE MEDIAKEY AND PREVIEWIMAGE
			if(preg_match('#param name="movie" value="[^&]+&flv=(?P<mediakey>[^&]+)&preview=http://mitworld\.mit\.edu//uploads/(?P<previewimage>[^"]+)"#si', $match['embedhtml'], $info))
			{
				// DEFINE GENERIC EMBED HTML WITH REPLACEMENT VARIABLES, __MEDIAKEY__ AND __PREVIEWIMAGE__
				$embedHtml = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="481" height="271" id="Main" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="http://mitworld.mit.edu/flash/player/Main.swf?host=cp58255.edgefcs.net&flv=__MEDIAKEY__&preview=http://mitworld.mit.edu//uploads/__PREVIEWIMAGE__" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<embed src="http://mitworld.mit.edu/flash/player/Main.swf?host=cp58255.edgefcs.net&flv=__MEDIAKEY__&preview=http://mitworld.mit.edu//uploads/__PREVIEWIMAGE__" quality="high" bgcolor="#000000" width="481" height="271" name="Main" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>';

				// MAKE THE REPLACEMENTS
				$finalHtml = str_replace(array('__MEDIAKEY__', '__PREVIEWIMAGE__'), array($info['mediakey'], $info['previewimage']), $embedHtml);

				// RETURN THE FINISHED HTML
				return $finalHtml;
			}
		}

		// RETURN NOTHING IF NO MATCH
		return '';
	}
}

URLs tested:
http://mitworld.mit.edu/video/931
http://mitworld.mit.edu/video/934
http://mitworld.mit.edu/video/923
 

Attachments

Also, you mentioned something about TED video 6 months ago. Is it possible to embed TED video now?
http://xenforo.com/community/threads/how-can-i-embed-ted-com-videos.14713/#post-192616

Yep it works now. It is similar to the MIT one actually:

Admin CP -> Home -> BB Code Media Sites -> Add BB Code Media Site

Media Site ID: ted

Site Title: TED

Site URL: http://www.ted.com/

Match URLs: http://www.ted.com/talks/{$id}.html

Embed HTML:

Code:
<see html callback>

Then under Advanced Options:

Embed HTML Callback: MediaSites_TED::buildEmbed

And you need to create the following directory/file (also attached to this post):

library/MediaSites/TED.php

Code:
<?php

class MediaSites_TED
{
	public static function buildEmbed($mediaKey, array $site)
	{
		// CAPTURE WEB PAGE
		$pageHtml = file_get_contents('http://www.ted.com/talks/' . $mediaKey . '.html');

		// ISOLATE THE EMBED CODE FROM THE PAGE SOURCE
		if(preg_match('/[^\w]input id="embedCode" class="copy_paste" type="text" readonly="readonly" value="(?P<embedhtml>[^"]+)"/siU', $pageHtml, $match))
		{
			// IT HAS HTML ENTITIES, UNDO THAT
			$match['embedhtml'] = htmlspecialchars_decode($match['embedhtml']);

			// FROM EMBED CODE, ISOLATE THE FLASHVARS
			if(preg_match('#param name="flashvars" value="(?P<flashvars>[^"]+)"#si', $match['embedhtml'], $info))
			{
				// DEFINE GENERIC EMBED HTML WITH REPLACEMENT VARIABLE, __FLASHVARS__
				$embedHtml = '<object width="526" height="374">
<param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param>
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always"/>
<param name="wmode" value="transparent"></param>
<param name="bgColor" value="#ffffff"></param>
<param name="flashvars" value="__FLASHVARS__" />
<embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="526" height="374" allowFullScreen="true" allowScriptAccess="always" flashvars="__FLASHVARS__"></embed>
</object>';

				// MAKE THE REPLACEMENT
				$finalHtml = str_replace('__FLASHVARS__', $info['flashvars'], $embedHtml);

				// RETURN THE FINISHED HTML
				return $finalHtml;
			}
		}

		// RETURN NOTHING IF NO MATCH
		return '';
	}
}

URLs tested:
http://www.ted.com/talks/guy_philippe_goldstein_how_cyberattacks_threaten_real_world_peace.html
http://www.ted.com/talks/misha_glenny_hire_the_hackers.html
 

Attachments


Easy one.

Admin CP -> Home -> BB Code Media Sites -> Add BB Code Media Site

Media Site ID: wsj

Site Title: Wall Street Journal

Site URL: http://online.wsj.com/video-center

Match URLs: http://online.wsj.com/video/*/{$id}.html

Embed HTML:

Code:
<object id="wsj_fp" width="512" height="363">
<param name="movie" value="http://s.wsj.net/media/swf/VideoPlayerMain.swf"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<param name="flashvars" value="videoGUID={{$id}}&playerid=1000&plyMediaEnabled=1&configURL=http://wsj.vo.llnwd.net/o28/players/&autoStart=false" base="http://s.wsj.net/media/swf/"name="flashPlayer"></param>
<embed src="http://s.wsj.net/media/swf/VideoPlayerMain.swf" bgcolor="#FFFFFF"flashVars="videoGUID={{$id}}&playerid=1000&plyMediaEnabled=1&configURL=http://wsj.vo.llnwd.net/o28/players/&autoStart=false" base="http://s.wsj.net/media/swf/" name="flashPlayer" width="512" height="363" seamlesstabbing="false" type="application/x-shockwave-flash" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>
</object>

URLs tested:
http://online.wsj.com/video/remembe...9B39-B42D40518C29.html?mod=WSJ_hpp_mpvidcar_1
http://online.wsj.com/video/medical...ton/4BA81633-E4CC-4A2E-B503-9F1DEB6542BA.html
 

Admin CP -> Home -> BB Code Media Sites -> Add BB Code Media Site

Media Site ID: pbs

Site Title: PBS Video

Site URL: http://video.pbs.org/

Match URLs: http://video.pbs.org/video/{$id}

Embed HTML:

Code:
<object width = "512" height = "328" >
<param name = "movie" value = "http://www-tc.pbs.org/video/media/swf/PBSPlayer.swf" ></param>
<param name="flashvars" value="video={$id}&player=viral&chapter=1" />
<param name="allowFullScreen" value="true"></param >
<param name = "allowscriptaccess" value = "always" ></param>
<param name="wmode" value="transparent"></param >
<embed src="http://www-tc.pbs.org/video/media/swf/PBSPlayer.swf" flashvars="video={$id}&player=viral&chapter=1" type="application/x-shockwave-flash" allowscriptaccess="always" wmode="transparent" allowfullscreen="true" width="512" height="328" bgcolor="#000000"></embed>
</object>

URLs tested:
http://video.pbs.org/video/1082087546
http://video.pbs.org/video/2151510911/
 

Admin CP -> Home -> BB Code Media Sites -> Add BB Code Media Site

Media Site ID: cnbc

Site Title: CNBC

Site URL: http://video.cnbc.com/

Match URLs: http://video.cnbc.com/gallery/?video={$id}

Embed HTML:

Code:
<object id="cnbcplayer" height="380" width="400" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" >
<param name="type" value="application/x-shockwave-flash"/>
<param name="allowfullscreen" value="true"/>
<param name="allowscriptaccess" value="always"/>
<param name="quality" value="best"/>
<param name="scale" value="noscale" />
<param name="wmode" value="transparent"/>
<param name="bgcolor" value="#000000"/>
<param name="salign" value="lt"/>
<param name="flashVars" value="startTime=000"/>
<param name="flashVars" value="endTime=000"/>
<param name="movie" value="http://plus.cnbc.com/rssvideosearch/action/player/id/{$id}/code/cnbcplayershare" />
<embed name="cnbcplayer" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" allowscriptaccess="always" bgcolor="#000000" height="380" width="400" quality="best" wmode="transparent" scale="noscale" salign="lt" src="http://plus.cnbc.com/rssvideosearch/action/player/id/{$id}/code/cnbcplayershare" type="application/x-shockwave-flash" />
</object>

URLs tested:
http://video.cnbc.com/gallery/?video=1487995510
http://video.cnbc.com/gallery/?video=3000052498
 

Admin CP -> Home -> BB Code Media Sites -> Add BB Code Media Site

Media Site ID: ign

Site Title: IGN

Site URL: http://uk.ign.com/videos/

Match URLs: #http://uk\.ign\.com/videos/(?P<id>\d+/\d+/\d+/[\-a-z0-9_]+)(\?.*)?$#siU

Embed HTML:

Code:
<object id="vid_ign" class="ign-videoplayer" width="480" height="270" data="http://media.ign.com/ev/prod/embed.swf" type="application/x-shockwave-flash">
<param name="movie" value="http://media.ign.com/ev/prod/embed.swf" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="bgcolor" value="#000000" />
<param name="flashvars" value="url=http://uk.ign.com/videos/{$id}"/>
</object>

And be sure to enable Use 'Match URLs' as PCRE regular expressions under Advanced Options.

URLs tested:
http://uk.ign.com/videos/2011/10/21...take-it-to-the-track-gameplay?objectid=108942
http://uk.ign.com/videos/2011/10/21...trip-make-a-new-kart-gameplay?objectid=108942
 
Thanks for that, I figured it may need some of 1.1's new features. Just make sure to add
Code:
<PARAM NAME=wmode VALUE="opaque">
so that it doesn't overlay on top of xenforo's pop-ups.

Also, is it possible to get it to work with the non-uk version without creating it as a separate media site? It seems to have the same structure besides for the subdomain.
 
If it's the same URL structure except for the subdomain then this should work:

Match URLs: #http://[a-z0-9]+\.ign\.com/videos/(?P<id>\d+/\d+/\d+/[\-a-z0-9_]+)(\?.*)?$#siU

If you give me a video URL then I can test it.

edit - the embed code also references the subdomain, so this may require more advanced code.
 
Top Bottom