Extension talk: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
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)
- 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)
Alignment on pages... future feature?
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)
- 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)
- 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)
Update which gives the possibility to upload and use "webm", "mp4" and "og" video files as alternatives
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)
- 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)
<track> tag and/or VTT support?
Nice work on this plugin--looks ace. Would it be possible to support captioning? 68.111.196.254 00:52, 15 June 2015 (UTC)
Extension loads JavaScript from third party server
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)
- 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:
- Jlemley (talk) 20:29, 6 September 2017 (UTC)
$wgResourceModules ['ext.Html5mediator.js'] = array ( 'localBasePath' => __DIR__ . '/js', 'remoteExtPath' => 'Html5mediator/js', 'scripts' => 'html5media.min.js' );
excelent
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)
html5mediator : error loading file (template)
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 ?
Making template using html5mediator
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)
- 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)