Open main menu

Extension talk:Html5mediator

About this board

189.217.121.254 (talkcontribs)

this extension although it is simple finally could insert a video of youtube to big size because the extension youtube and others did not do it for that many congratulations for the author that I believe this extension I hope that they do not archive it and last many more years.

Reply to "excelent"

Extension loads JavaScript from third party server

2
Tonk (talkcontribs)

The extensions loads JavaScript from api.html5media.info/1.1.5/html5media.min.js - over an unsecured HTTP-connection. This is not mentioned on the extension page though it has severe security implications. Extensions should be self-contained; for a secure setup, no third party content must be loaded.

Jlemley (talkcontribs)

I followed the instructions here:

https://github.com/etianen/html5media/wiki/hosting-html5media

I copied the files to a "js" directory under the Html5mediator directory, and then added these lines after $wgHooks in the php file:

$wgResourceModules ['ext.Html5mediator.js'] = array (
     'localBasePath' => __DIR__ . '/js',
     'remoteExtPath' => 'Html5mediator/js',
     'scripts' => 'html5media.min.js'
);


Reply to "Extension loads JavaScript from third party server"

Update which gives the possibility to upload and use "webm", "mp4" and "og" video files as alternatives

2
Baxi69 (talkcontribs)

I made an update for this extension. I did not touch the original functioning of the extension.


You can now add the 3 additional parameters webm, mp4 and ogv in the <html5media> tag.


When you add minimum one of the 3 parameters, the extension will work in alternatives mode. In this case you must not give the file extension of the videa file.


Example: <html5media mp4 webm>File:SampleVideo</html5media> For this example you have to upload the two files SampleVideo.mp4 and SampleVideo.webm. If someone will access this page with Opera SampleVideo.webm will be shown, with Firefox SampleVideo.mp4 will be shown.


To install the update just replace the file /etensions/Html5mediator/Html5mediator.php with the following source code:


<?php

if ( !defined( 'MEDIAWIKI' ) ) die();

$wgExtensionCredits['html5mediator'][] = array(
	'path' => __FILE__,
	'name' => 'Html5mediator',
	'url' => 'https://www.mediawiki.org/wiki/Extension:Html5mediator',
	'description' => 'A simple way to embed audio and video files in a wiki',
	'author' => 'Seung Park, Update: Frank Baxmann'
 	);

/* Register the registration function */
$wgHooks['ParserFirstCallInit'][] = 'wfHtml5Mediator';

function wfHtml5Mediator($parser)
{
	$parser->setHook('html5media' , 'wfHtml5MediatorParse');
	return true;
}

function wfHtml5MediatorParse($data, $params, $parser, $frame)
{
	global $wgContLang;
	
	// init the VideoFormatList
	$videoFormats = null;

	// escape from XSS vulnerabilities
	foreach ($params as $param => $paramval)
	{
		$params[$param] = htmlspecialchars ($paramval);
		if (isset($params['mp4'])) 
		{
			$videoFormats [] = "mp4";
		}
		if (isset($params['webm'])) 
		{
			$videoFormats [] = "webm";
		}
		if (isset($params['ogv']))
		{
			$videoFormats [] = "ogv";
		}
	}
	$data = htmlspecialchars($data);


	// load international name of File namespace
	$namespaceNames = $wgContLang->getNamespaces();
	$fileNS = strtolower($namespaceNames[NS_FILE]);
	$ns = strtolower(strstr($data,':',true));

	// check to see if a file specified
	if ($ns == 'file' || $ns == $fileNS)
	{
		if (!isset ($videoFormats))
		{
			$image = wfFindFile(substr(strstr($data,':'), 1));
			if ($image)
			{
				$data = $image->getFullURL();
			}
			else
			{
				return 'Html5mediator: error loading file:' . Xml::encodeJsVar(substr($data, 5));
			}
		} else
		{
			foreach ($videoFormats as &$format)
			{
				$image = wfFindFile(substr(strstr($data,':'), 1) . "." . $format);
				if ($image)
				{
					$format = $image->getFullURL();
				} // end if
				else
				{
					return 'Html5mediator: error loading file:' . Xml::encodeJsVar(substr(strstr($data,':'), 1) . "." . $format);
				} // end else
				
			} //end foreach
		} // end else
	}

	// Perform validation on the purported URL
	if ((!isset ($videoFormats)) and (!filter_var($data, FILTER_VALIDATE_URL))) return 'Html5mediator: 10 not a valid URL';
	if (isset($videoFormats))
	{
		foreach ($videoFormats as $formatURL)
		{
			if (!filter_var($formatURL, FILTER_VALIDATE_URL)) return 'Html5mediator: 20 not a valid URL: ' . $formatURL;
		} //end for each
	} // end if

	// Get the file extension -- first check for a 3-char extension (mp3, mp4), then 4-char (webm)
	if (!isset ($videoFormats))
	{
		if (substr($data, -4, 1) == ".") $ext = substr($data, -3);
		else if (substr($data, -5, 1) == ".") $ext = substr($data, -4);
		else if (strtolower(substr($data, 0, 23)) == "http://www.youtube.com/" || strtolower(substr($data, 0, 24)) == "https://www.youtube.com/") $ext = "youtube";
	} //end if

	// Write out the actual HTML
	$code = "<script src=\"http://api.html5media.info/1.1.5/html5media.min.js\"></script>";

	if (!isset ($videoFormats))
	{
		switch ($ext)
		{
			// video file extensions
			case "mp4":
			case "webm":
			case "mov":
			case "ogv":
				$code = $code . "<video src=\"" . $data . "\" controls";
				foreach ($params as $param => $paramval)
				{
					$code = $code . " " . htmlspecialchars($param) . "=\"" . $paramval . "\"";
				}
				$code = $code . "></video>";
				break;

			// audio file extensions
			case "mp3":
			case "ogg":
				$code = $code . "<audio src=\"" . $data . "\" controls preload";
				foreach ($params as $param => $paramval)
				{
					$code = $code . " " . htmlspecialchars($param) . "=\"" . $paramval . "\"";
				}
				$code = $code . "></audio>";
				break;
			
			// youtube
			case "youtube":
				$code = "<iframe";
				foreach ($params as $param => $paramval)
				{
					$code = $code . " " . htmlspecialchars($param) . "=\"" . $paramval . "\"";
				}
				$code = $code . " src=\"//www.youtube.com/embed/" . substr($data, -11) . "?rel=0\" frameborder=\"0\" allowfullscreen></iframe>";
				break;

			// unrecognized file extensions
			default:
				return "Html5mediator: 30 file extension not recognized";
		} // end switch
	} else // create the lines for the videoFormats
	{
		$code = $code . "<video controls";
				foreach ($params as $param => $paramval)
				{
					if (($param <> "webm") and ($param <> "mp4") and ($param <> "ogv"))
					{
						$code = $code . " " . htmlspecialchars($param) . "=\"" . $paramval . "\"";
					} // end if
				}
				$code = $code . ">";
				foreach ($videoFormats as $formatURL)
				{
					$code = $code . "<source src=\"" . $formatURL . "\"></source>";
				}
				$code = $code . "</video>";
	} // end else

	return $code;
}

?>
129.94.63.59 (talkcontribs)

This works for me, but I had to switch the "$data = $image->getFullURL();" lines to "$data = $image->getCanonicalURL();" as I use a protocol-independant $wgServer setting, so there was no http: or https: at the front of the File names resulting in an error 20. Not sure if there's a better way to do it.

Reply to "Update which gives the possibility to upload and use "webm", "mp4" and "og" video files as alternatives"

<track> tag and/or VTT support?

1
68.111.196.254 (talkcontribs)

Nice work on this plugin--looks ace. Would it be possible to support captioning?

Reply to "<track> tag and/or VTT support?"

Alignment on pages... future feature?

3
78.33.162.186 (talkcontribs)

I'm possibly being a muppet so forgive me if this is already possible... but at present I can't seem to figure out how to align videos to the center/right of the page. They all seem to be left-aligned. Is there no support for alignment of media on the page at this point in time?

Other than that this extension works great! Love it.

78.33.162.186 (talkcontribs)

As an afterthought... wrapping the <html5media> tags in <p> tags with alignment added in work just fine for justifying videos left/right/center:

<p align="center"><html5media height="240" width="320">File:video_name_here.mp4</html5media></p>



Never mind, I suppose!

Lightbinder (talkcontribs)

Hi there!

I'm glad you found a way to get your videos to justify left/right/center. I agree that it would be nice to have this kind of capability directly in Html5mediator itself; I've added it to the features to be implemented for Html5mediator v0.4.

Thanks so much for using my extension!

Reply to "Alignment on pages... future feature?"
94.175.211.243 (talkcontribs)

yes I would welcome this addition to the extension. Using it on 1.20.2 appears stable.

Lightbinder (talkcontribs)

Thank you for your comment! Please try out the newly-released version 0.2 -- it adds support for custom height and width.

Reply to "Hight and width control"
There are no older topics
Return to "Html5mediator" page.