Jump to content
MediaWiki

Extension talk:Html5mediator

Add topic
From mediawiki.org
Latest comment: 6 years ago by 91.231.18.10 in topic Making template using html5mediator
This page used the Structured Discussions extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made.


Hight and width control

[edit ]
Latest comment: 12 years ago 2 comments2 people in discussion

yes I would welcome this addition to the extension. Using it on 1.20.2 appears stable. 94.175.211.243 09:09, 6 September 2013 (UTC) Reply

Thank you for your comment! Please try out the newly-released version 0.2 -- it adds support for custom height and width. Lightbinder (talk) 03:39, 7 September 2013 (UTC) Reply

Alignment on pages... future feature?

[edit ]
Latest comment: 12 years ago 3 comments2 people in discussion

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 11:50, 7 October 2013 (UTC) Reply

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! 78.33.162.186 12:08, 7 October 2013 (UTC) Reply
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! Lightbinder (talk) 02:07, 15 October 2013 (UTC) Reply

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

[edit ]
Latest comment: 12 years ago 2 comments2 people in discussion

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;
}
?>

Baxi69 (talk) 20:12, 21 January 2014 (UTC) Reply

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. 129.94.63.59 04:40, 18 June 2014 (UTC) Reply

_tag_and/or_VTT_support?" data-mw-thread-id="h-
_tag_and/or_VTT_support?-2015年06月15日T00:52:00.000Z">_tag_and/or_VTT_support?-2015年06月15日T00:52:00.000Z"><track> tag and/or VTT support?_tag_and/or_VTT_support?-2015年06月15日T00:52:00.000Z">

[ tag and/or VTT support?">edit ]
Latest comment: 11 years ago 1 comment1 person in discussion

_tag_and/or_VTT_support?">Nice work on this plugin--looks ace. Would it be possible to support captioning? _tag_and/or_VTT_support?">68.111.196.254 _tag_and/or_VTT_support?" class="ext-discussiontools-init-timestamplink" title="11 years ago">00:52, 15 June 2015 (UTC) _tag_and/or_VTT_support?">Reply _tag_and/or_VTT_support?">

Extension loads JavaScript from third party server

[edit ]
Latest comment: 8 years ago 2 comments2 people in discussion

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. Tonk (talk) 10:20, 8 May 2017 (UTC) Reply

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'
);
Jlemley (talk) 20:29, 6 September 2017 (UTC) Reply

excelent

[edit ]
Latest comment: 7 years ago 1 comment1 person in discussion

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. 189.217.121.254 (talk) 03:28, 18 January 2019 (UTC) Reply

html5mediator : error loading file (template)

[edit ]
Latest comment: 7 years ago 2 comments1 person in discussion

Hello,


It looks like html5 mediator tries to read the "file" in the template (here {{son}} instead of including the declared template value) : https://dicoado.org/dico/iris


Any idea how to make it work ?


Thanks DSwissK (talk) 21:23, 15 February 2019 (UTC) Reply

If anyone encounters the same problem :
#tag did the trick DSwissK (talk) 13:56, 16 February 2019 (UTC) Reply

Making template using html5mediator

[edit ]
Latest comment: 6 years ago 2 comments1 person in discussion

Hello, I wonder if it's possible to make a template using this extension. Currently when I am trying to make a template:

<html5media height="600" width="900">File:{{{1}}}</html5media>

I am getting an error: Html5mediator: error loading file:"{{{1}}}"

File is .mp4, and it works when I use it without a template:

<html5media height="600" width="900">File:Name_of_the_file.mp4</html5media>

Any solutions?


Thanks. :) 91.231.18.10 (talk) 07:15, 13 September 2019 (UTC) Reply

Mediawiki version: 1.33.0
Btw is it possible to use this extension with .flv? 91.231.18.10 (talk) 07:16, 13 September 2019 (UTC) Reply

AltStyle によって変換されたページ (->オリジナル) /