2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Media plugin filtering
20 * This filter will replace any links to a media file with
21 * a media plugin that plays that media inline
24 * @subpackage mediaplugin
25 * @copyright 2004 onwards Martin Dougiamas {@link http://moodle.com}
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 defined('MOODLE_INTERNAL') ||
die();
31 require_once($CFG->libdir
.'/filelib.php');
33 if (!defined('FILTER_MEDIAPLUGIN_VIDEO_WIDTH')) {
35 * Default media width, some plugins may use automatic sizes or accept resize parameters.
36 * This can be defined in config.php.
38 define('FILTER_MEDIAPLUGIN_VIDEO_WIDTH', 400);
41 if (!defined('FILTER_MEDIAPLUGIN_VIDEO_HEIGHT')) {
43 * Default video height, plugins that know aspect ration
44 * should calculate it themselves using the FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
45 * This can be defined in config.php.
47 define('FILTER_MEDIAPLUGIN_VIDEO_HEIGHT', 300);
51 //TODO: we should use /u modifier in regex, unfortunately it may not work properly on some misconfigured servers, see lib/filter/urltolink/filter.php ...
53 //TODO: we should migrate to proper config_plugin settings ...
57 * Automatic media embedding filter class.
59 * It is highly recommended to configure servers to be compatible with our slasharguments,
60 * otherwise the "?d=600x400" may not work.
63 * @subpackage mediaplugin
64 * @copyright 2004 onwards Martin Dougiamas {@link http://moodle.com}
65 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
67 class filter_mediaplugin
extends moodle_text_filter
{
69 function filter($text, array $options = array()) {
72 if (!is_string($text) or empty($text)) {
73 // non string data can not be filtered anyway
76 if (stripos($text, '</a>') === false) {
77 // performance shortcut - all regexes bellow end with the </a> tag,
78 // if not present nothing can match
82 $newtext = $text; // we need to return the original value if regex fails!
84 // YouTube and Vimeo are great because the files are not served by Moodle server
86 if (!empty($CFG->filter_mediaplugin_enable_youtube
)) {
87 $search = '/<a\s[^>]*href="(https?:\/\/www\.youtube(-nocookie)?\.com)\/watch\?v=([a-z0-9\-_]+)[^"#]*(#d=([\d]{1,4})x([\d]{1,4}))?"[^>]*>([^>]*)<\/a>/is';
88 $newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
90 $search = '/<a\s[^>]*href="(https?:\/\/www\.youtube(-nocookie)?\.com)\/v\/([a-z0-9\-_]+)[^"#]*(#d=([\d]{1,4})x([\d]{1,4}))?[^>]*>([^>]*)<\/a>/is';
91 $newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
93 $search = '/<a\s[^>]*href="(https?:\/\/www\.youtube(-nocookie)?\.com)\/view_play_list\?p=([a-z0-9\-_]+)[^"#]*(#d=([\d]{1,4})x([\d]{1,4}))?[^>]*>([^>]*)<\/a>/is';
94 $newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_playlist_callback', $newtext);
96 $search = '/<a\s[^>]*href="(https?:\/\/www\.youtube(-nocookie)?\.com)\/p\/([a-z0-9\-_]+)[^"#]*(#d=([\d]{1,4})x([\d]{1,4}))?[^>]*>([^>]*)<\/a>/is';
97 $newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_playlist_callback', $newtext);
100 if (!empty($CFG->filter_mediaplugin_enable_vimeo
)) {
101 $search = '/<a\s[^>]*href="http:\/\/vimeo\.com\/([0-9]+)[^"#]*(#d=([\d]{1,4})x([\d]{1,4}))?[^>]*>([^>]*)<\/a>/is';
102 $newtext = preg_replace_callback($search, 'filter_mediaplugin_vimeo_callback', $newtext);
106 // HTML 5 audio and video tags are the future! If only if vendors decided to use just one audio and video format...
108 if (!empty($CFG->filter_mediaplugin_enable_html5audio
)) {
109 $search = '/<a\s[^>]*href="([^"#\?]+\.(ogg|oga|aac|m4a)([#\?][^"]*)?)"[^>]*>([^>]*)<\/a>/is';
110 $newtext = preg_replace_callback($search, 'filter_mediaplugin_html5audio_callback', $newtext);
113 if (!empty($CFG->filter_mediaplugin_enable_html5video
)) {
114 $search = '/<a\s[^>]*href="([^"#\?]+\.(m4v|webm|ogv|mp4)([#\?][^"]*)?)"[^>]*>([^>]*)<\/a>/is';
115 $newtext = preg_replace_callback($search, 'filter_mediaplugin_html5video_callback', $newtext);
121 if (!empty($CFG->filter_mediaplugin_enable_mp3
)) {
122 $search = '/<a\s[^>]*href="([^"#\?]+\.mp3)"[^>]*>([^>]*)<\/a>/is';
123 $newtext = preg_replace_callback($search, 'filter_mediaplugin_mp3_callback', $newtext);
126 if ((!empty($options['noclean']) or !empty($CFG->allowobjectembed
)) and !empty($CFG->filter_mediaplugin_enable_swf
)) {
127 $search = '/<a\s[^>]*href="([^"#\?]+\.swf)([#\?]d=([\d]{1,4})x([\d]{1,4}))?"[^>]*>([^>]*)<\/a>/is';
128 $newtext = preg_replace_callback($search, 'filter_mediaplugin_swf_callback', $newtext);
131 if (!empty($CFG->filter_mediaplugin_enable_flv
)) {
132 $search = '/<a\s[^>]*href="([^"#\?]+\.(flv|f4v)([#\?][^"]*)?)"[^>]*>([^>]*)<\/a>/is';
133 $newtext = preg_replace_callback($search, 'filter_mediaplugin_flv_callback', $newtext);
137 // The rest of legacy formats - these should not be used if possible
139 if (!empty($CFG->filter_mediaplugin_enable_wmp
)) {
140 $search = '/<a\s[^>]*href="([^"#\?]+\.(wmv|avi))(\?d=([\d]{1,4})x([\d]{1,4}))?"[^>]*>([^>]*)<\/a>/is';
141 $newtext = preg_replace_callback($search, 'filter_mediaplugin_wmp_callback', $newtext);
144 if (!empty($CFG->filter_mediaplugin_enable_qt
)) {
145 // HTML5 filtering may steal mpeg 4 formats
146 $search = '/<a\s[^>]*href="([^"#\?]+\.(mpg|mpeg|mov|mp4|m4v|m4a))(\?d=([\d]{1,4})x([\d]{1,4}))?"[^>]*>([^>]*)<\/a>/is';
147 $newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
150 if (!empty($CFG->filter_mediaplugin_enable_rm
)) {
151 // hopefully nobody is using this any more!!
152 // rpm is redhat packaging format these days, it is better to prevent these in default installs
154 $search = '/<a\s[^>]*href="([^"#\?]+\.(ra|ram|rm|rv))"[^>]*>([^>]*)<\/a>/is';
155 $newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext);
159 if (empty($newtext) or $newtext === $text) {
160 // error or not filtered
171 ///===========================
172 /// utility functions
176 * Parse list of alternative URLs
177 * @param string $url urls separated with '#', size specified as ?d=640x480 or #d=640x480
178 * @return array (urls, width, height)
180 function filter_mediaplugin_parse_alternatives($url, $defaultwidth = 0, $defaultheight = 0) {
181 $urls = explode('#', $url);
182 $width = $defaultwidth;
183 $height = $defaultheight;
184 $returnurls = array();
186 foreach ($urls as $url) {
189 if (preg_match('/^d=([\d]{1,4})x([\d]{1,4})$/i', $url, $matches)) { // #d=640x480
190 $width = $matches[1];
191 $height = $matches[2];
194 if (preg_match('/\?d=([\d]{1,4})x([\d]{1,4})$/i', $url, $matches)) { // old style file.ext?d=640x480
195 $width = $matches[1];
196 $height = $matches[2];
197 $url = str_replace($matches[0], '', $url);
200 $url = str_replace('&', '&', $url);
201 $url = clean_param($url, PARAM_URL
);
206 $returnurls[] = $url;
209 return array($returnurls, $width, $height);
213 * Should the current tag be ignored in this filter?
217 function filter_mediaplugin_ignore($tag) {
218 if (preg_match('/class="[^"]*nomediaplugin/i', $tag)) {
225 ///===========================
226 /// callback filter functions
230 * Replace audio links with audio tag.
235 function filter_mediaplugin_html5audio_callback(array $link) {
238 if (filter_mediaplugin_ignore($link[0])) {
242 $info = trim($link[4]);
243 if (empty($info) or strpos($info, 'http') === 0) {
244 $info = get_string('fallbackaudio', 'filter_mediaplugin');
247 list($urls, $ignorewidth, $ignoredheight) = filter_mediaplugin_parse_alternatives($link[1]);
250 $fallbackmime = null;
252 $fallbacklink = null;
254 foreach ($urls as $url) {
255 $mimetype = mimeinfo('type', $url);
256 if (strpos($mimetype, 'audio/') !== 0) {
259 $sources[] = html_writer
::tag('source', '', array('src' => $url, 'type' => $mimetype));
261 if ($fallbacklink === null) {
262 $fallbacklink = html_writer
::link($url.'#', $info); // the extra '#' prevents linking in mp3 filter bellow
264 if ($fallbackurl === null) {
265 if ($mimetype === 'audio/mp3' or $mimetype === 'audio/aac') {
266 $fallbackurl = str_replace('&', '&', $url);
267 $fallbackmime = $mimetype;
275 if ($fallbackmime !== null) {
276 // fallback to quicktime
278 <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="200" height="20">
279 <param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
280 <param name="src" value="$fallbackurl" />
281 <param name="controller" value="true" />
282 <param name="loop" value="false" />
283 <param name="autoplay" value="false" />
284 <param name="autostart" value="false" />
285 <param name="scale" value="aspect" />
288 <object data="$fallbackurl" type="$fallbackmime" width="200" height="20">
289 <param name="src" value="$fallbackurl" />
290 <param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
291 <param name="controller" value="true" />
292 <param name="loop" value="false" />
293 <param name="autoplay" value="false" />
294 <param name="autostart" value="false" />
295 <param name="scale" value="aspect" />
302 $fallback = $fallbacklink;
305 $sources = implode("\n", $sources);
308 // audio players are supposed to be inline elements
310 <audio controls="true" width="200" class="mediaplugin mediaplugin_html5audio" preload="no" title="$title">
320 * Replace ogg video links with video tag.
322 * Please note this is not going to work in all browsers,
323 * it is also not xhtml strict.
328 function filter_mediaplugin_html5video_callback(array $link) {
330 if (filter_mediaplugin_ignore($link[0])) {
334 $info = trim($link[4]);
335 if (empty($info) or strpos($info, 'http') === 0) {
336 $info = get_string('fallbackvideo', 'filter_mediaplugin');
339 list($urls, $width, $height) = filter_mediaplugin_parse_alternatives($link[1], FILTER_MEDIAPLUGIN_VIDEO_WIDTH
, 0);
342 $fallbackmime = null;
344 $fallbacklink = null;
346 foreach ($urls as $url) {
347 $mimetype = mimeinfo('type', $url);
348 if (strpos($mimetype, 'video/') !== 0) {
351 $source = html_writer
::tag('source', '', array('src' => $url, 'type' => $mimetype));
352 if ($mimetype === 'video/mp4') {
353 // better add m4v as first source, it might be a bit more compatible with problematic browsers
354 array_unshift($sources, $source);
356 $sources[] = $source;
359 if ($fallbacklink === null) {
360 $fallbacklink = html_writer
::link($url.'#', $info); // the extra '#' prevents linking in mp3 filter bellow
362 if ($fallbackurl === null) {
363 if ($mimetype === 'video/mp4') {
364 $fallbackurl = str_replace('&', '&', $url);
365 $fallbackmime = $mimetype;
373 if ($fallbackmime !== null) {
374 $qtheight = ($height == 0) ? FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
: ($height +
15);
375 // fallback to quicktime
377 <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="$width" height="$qtheight">
378 <param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
379 <param name="src" value="$fallbackurl" />
380 <param name="controller" value="true" />
381 <param name="loop" value="false" />
382 <param name="autoplay" value="false" />
383 <param name="autostart" value="false" />
384 <param name="scale" value="aspect" />
387 <object data="$fallbackurl" type="$fallbackmime" width="$width" height="$qtheight">
388 <param name="src" value="$fallbackurl" />
389 <param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
390 <param name="controller" value="true" />
391 <param name="loop" value="false" />
392 <param name="autoplay" value="false" />
393 <param name="autostart" value="false" />
394 <param name="scale" value="aspect" />
401 $fallback = $fallbacklink;
404 $sources = implode("\n", $sources);
407 if (empty($height)) {
409 $size = "width=\"$width\"";
411 $size = "width=\"$width\" height=\"$height\"";
415 <span class="mediaplugin mediaplugin_html5video">
416 <video controls="true" $size preload="metadata" title="$title">
427 * Replace mp3 links with small audio player.
432 function filter_mediaplugin_mp3_callback($link) {
435 if (filter_mediaplugin_ignore($link[0])) {
440 $id = 'filter_mp3_'.time().'_'.$count; //we need something unique because it might be stored in text cache
443 $rawurl = str_replace('&', '&', $url);
445 $info = trim($link[2]);
446 if (empty($info) or strpos($info, 'http') === 0) {
447 $info = get_string('mp3audio', 'filter_mediaplugin');
450 $printlink = html_writer
::link($rawurl, $info, array('class'=>'mediafallbacklink'));
452 //note: when flash or javascript not available only the $printlink is displayed,
453 // audio players are supposed to be inline elements
455 $output = html_writer
::tag('span', $printlink, array('id'=>$id, 'class'=>'mediaplugin mediaplugin_mp3'));
456 $output .= html_writer
::script(js_writer
::function_call('M.util.add_audio_player', array($id, $rawurl, true))); // we can not use standard JS init because this may be cached
462 * Replace swf links with embedded flash objects.
464 * Please note this is not a secure and is recommended to be disabled on production systems.
470 function filter_mediaplugin_swf_callback($link) {
472 if (filter_mediaplugin_ignore($link[0])) {
476 $width = empty($link[3]) ? FILTER_MEDIAPLUGIN_VIDEO_WIDTH
: $link[3];
477 $height = empty($link[4]) ? FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
: $link[4];
480 $rawurl = str_replace('&', '&', $url);
482 $info = trim($link[5]);
483 if (empty($info) or strpos($info, 'http') === 0) {
484 $info = get_string('flashanimation', 'filter_mediaplugin');
487 $printlink = html_writer
::link($rawurl, $info, array('class'=>'mediafallbacklink'));
490 <span class="mediaplugin mediaplugin_swf">
491 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="$width" height="$height">
492 <param name="movie" value="$url" />
493 <param name="autoplay" value="true" />
494 <param name="loop" value="true" />
495 <param name="controller" value="true" />
496 <param name="scale" value="aspect" />
497 <param name="base" value="." />
498 <param name="allowscriptaccess" value="never" />
500 <object type="application/x-shockwave-flash" data="$url" width="$width" height="$height">
501 <param name="controller" value="true" />
502 <param name="autoplay" value="true" />
503 <param name="loop" value="true" />
504 <param name="scale" value="aspect" />
505 <param name="base" value="." />
506 <param name="allowscriptaccess" value="never" />
521 * Replace flv links with flow player.
526 function filter_mediaplugin_flv_callback($link) {
529 if (filter_mediaplugin_ignore($link[0])) {
534 $id = 'filter_flv_'.time().'_'.$count; //we need something unique because it might be stored in text cache
536 list($urls, $width, $height) = filter_mediaplugin_parse_alternatives($link[1], 0, 0);
539 if (!$width and !$height) {
540 $width = FILTER_MEDIAPLUGIN_VIDEO_WIDTH
;
541 $height = FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
;
548 foreach ($urls as $url) {
549 $mimetype = mimeinfo('type', $url);
550 if (strpos($mimetype, 'video/') !== 0) {
553 $source = html_writer
::tag('source', '', array('src' => $url, 'type' => $mimetype));
554 if ($mimetype === 'video/mp4') {
555 // better add m4v as first source, it might be a bit more compatible with problematic browsers
556 array_unshift($sources, $source);
558 $sources[] = $source;
561 if ($flashurl === null) {
562 $flashurl = str_replace('&', '&', $url);
569 $info = trim($link[4]);
570 if (empty($info) or strpos($info, 'http') === 0) {
571 $info = get_string('fallbackvideo', 'filter_mediaplugin');
573 $printlink = html_writer
::link($flashurl.'#', $info, array('class'=>'mediafallbacklink')); // the '#' prevents the QT filter
577 if (count($sources) > 1) {
578 $sources = implode("\n", $sources);
582 <video controls="true" width="$width" height="$height" preload="metadata" title="$title">
592 // note: no need to print "this is flv link" because it is printed automatically if JS or Flash not available
594 $output = html_writer
::tag('span', $printlink, array('id'=>$id, 'class'=>'mediaplugin mediaplugin_flv'));
595 $output .= html_writer
::script(js_writer
::function_call('M.util.add_video_player', array($id, $flashurl, $width, $height, $autosize))); // we can not use standard JS init because this may be cached
601 * Replace real media links with real player.
603 * Note: hopefully nobody is using this obsolete format any more.
609 function filter_mediaplugin_real_callback($link) {
611 if (filter_mediaplugin_ignore($link[0])) {
616 $rawurl = str_replace('&', '&', $url);
618 //Note: the size is hardcoded intentionally because this does not work anyway!
620 $width = FILTER_MEDIAPLUGIN_VIDEO_WIDTH
;
621 $height = FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
;
623 $info = trim($link[3]);
624 if (empty($info) or strpos($info, 'http') === 0) {
625 $info = get_string('fallbackvideo', 'filter_mediaplugin');
627 $printlink = html_writer
::link($rawurl, $info, array('class'=>'mediafallbacklink'));
630 <span class="mediaplugin mediaplugin_real">
632 <object title="$info" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" data="$url" width="$width" height="$height"">
633 <param name="src" value="$url" />
634 <param name="controls" value="All" />
636 <object title="$info" type="audio/x-pn-realaudio-plugin" data="$url" width="$width" height="$height">
637 <param name="src" value="$url" />
638 <param name="controls" value="All" />
649 * Change links to YouTube into embedded YouTube videos
651 * Note: resizing via url is not supported, user can click the fullscreen button instead
656 function filter_mediaplugin_youtube_callback($link) {
659 if (filter_mediaplugin_ignore($link[0])) {
666 $info = trim($link[7]);
667 if (empty($info) or strpos($info, 'http') === 0) {
668 $info = get_string('siteyoutube', 'filter_mediaplugin');
672 $width = empty($link[5]) ? FILTER_MEDIAPLUGIN_VIDEO_WIDTH
: $link[5];
673 $height = empty($link[6]) ? FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
: $link[6];
675 if (empty($CFG->xmlstrictheaders
)) {
677 <iframe title="$info" width="$width" height="$height" src="$site/embed/$videoid?rel=0" frameborder="0" allowfullscreen></iframe>
681 //NOTE: we can not use any link fallback because it breaks built-in player on iOS devices
684 <span class="mediaplugin mediaplugin_youtube">
685 <object title="$info" type="application/x-shockwave-flash" data="$site/v/$videoid&fs=1&rel=0" width="$width" height="$height">
686 <param name="movie" value="$site/v/$videoid&fs=1&rel=0" />
687 <param name="FlashVars" value="playerMode=embedded" />
688 <param name="allowFullScreen" value="true" />
697 * Change YouTube playlist into embedded YouTube playlist videos
699 * Note: resizing via url is not supported, user can click the fullscreen button instead
704 function filter_mediaplugin_youtube_playlist_callback($link) {
707 if (filter_mediaplugin_ignore($link[0])) {
712 $playlist = $link[3];
714 $info = trim($link[7]);
715 if (empty($info) or strpos($info, 'http') === 0) {
716 $info = get_string('siteyoutube', 'filter_mediaplugin');
718 $printlink = html_writer
::link("$site/view_play_list\?p=$playlist", $info, array('class'=>'mediafallbacklink'));
721 $width = empty($link[5]) ? FILTER_MEDIAPLUGIN_VIDEO_WIDTH
: $link[5];
722 $height = empty($link[6]) ? FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
: $link[6];
724 // TODO: iframe HTML 5 video not implemented and object does work on iOS devices
727 <span class="mediaplugin mediaplugin_youtube">
728 <object title="$info" type="application/x-shockwave-flash" data="$site/p/$playlist&fs=1&rel=0" width="$width" height="$height">
729 <param name="movie" value="$site/v/$playlist&fs=1&rel=0" />
730 <param name="FlashVars" value="playerMode=embedded" />
731 <param name="allowFullScreen" value="true" />
740 * Change links to Vimeo into embedded Vimeo videos
745 function filter_mediaplugin_vimeo_callback($link) {
748 if (filter_mediaplugin_ignore($link[0])) {
753 $info = s(strip_tags($link[5]));
755 //Note: resizing via url is not supported, user can click the fullscreen button instead
756 // iframe embedding is not xhtml strict but it is the only option that seems to work on most devices
758 $width = empty($link[3]) ? FILTER_MEDIAPLUGIN_VIDEO_WIDTH
: $link[3];
759 $height = empty($link[4]) ? FILTER_MEDIAPLUGIN_VIDEO_HEIGHT
: $link[4];
762 <span class="mediaplugin mediaplugin_vimeo">
763 <iframe title="$info" src="http://player.vimeo.com/video/$videoid" width="$width" height="$height" frameborder="0"></iframe>
771 * Embed video using window media player if available
773 * This does not work much outside of IE, hopefully not many ppl use it these days.
778 function filter_mediaplugin_wmp_callback($link) {
780 if (filter_mediaplugin_ignore($link[0])) {
785 $rawurl = str_replace('&', '&', $url);
787 $info = trim($link[6]);
788 if (empty($info) or strpos($info, 'http') === 0) {
789 $info = get_string('fallbackvideo', 'filter_mediaplugin');
791 $printlink = html_writer
::link($rawurl, $info, array('class'=>'mediafallbacklink'));
793 if (empty($link[4]) or empty($link[5])) {
795 $size = 'width="'.FILTER_MEDIAPLUGIN_VIDEO_WIDTH
.'" height="'.(FILTER_MEDIAPLUGIN_VIDEO_HEIGHT+
64).'"';
798 $size = 'width="'.$link[4].'" height="'.($link[5] +
15).'"';
799 $mpsize = 'width="'.$link[4].'" height="'.($link[5] +
64).'"';
802 $mimetype = mimeinfo('type', $url);
807 <span class="mediaplugin mediaplugin_wmp">
809 <object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" $mpsize standby="Loading Microsoft(R) Windows(R) Media Player components..." type="application/x-oleobject">
810 <param name="Filename" value="$url" />
811 <param name="src" value="$url" />
812 <param name="url" value="$url" />
813 <param name="ShowControls" value="true" />
814 <param name="AutoRewind" value="true" />
815 <param name="AutoStart" value="false" />
816 <param name="Autosize" value="$autosize" />
817 <param name="EnableContextMenu" value="true" />
818 <param name="TransparentAtStart" value="false" />
819 <param name="AnimationAtStart" value="false" />
820 <param name="ShowGotoBar" value="false" />
821 <param name="EnableFullScreenControls" value="true" />
822 <param name="uimode" value="full" />
824 <object data="$url" type="$mimetype" $size>
825 <param name="src" value="$url" />
826 <param name="controller" value="true" />
827 <param name="autoplay" value="false" />
828 <param name="autostart" value="false" />
829 <param name="resize" value="scale" />
837 * Replace quicktime links with quicktime player.
839 * You need to install a quicktime player, it is not available for all browsers+OS combinations.
844 function filter_mediaplugin_qt_callback($link) {
846 if (filter_mediaplugin_ignore($link[0])) {
851 $rawurl = str_replace('&', '&', $url);
853 $info = trim($link[6]);
854 if (empty($info) or strpos($info, 'http') === 0) {
855 $info = get_string('fallbackvideo', 'filter_mediaplugin');
857 $printlink = html_writer
::link($rawurl, $info, array('class'=>'mediafallbacklink'));
859 if (empty($link[4]) or empty($link[5])) {
860 $size = 'width="'.FILTER_MEDIAPLUGIN_VIDEO_WIDTH
.'" height="'.(FILTER_MEDIAPLUGIN_VIDEO_HEIGHT+
15).'"';
862 $size = 'width="'.$link[4].'" height="'.($link[5]+
15).'"';
864 $mimetype = mimeinfo('type', $url);
866 // this is the safest fallback for incomplete or missing browser support for this format
868 <span class="mediaplugin mediaplugin_qt">
870 <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" $size>
871 <param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
872 <param name="src" value="$url" />
873 <param name="controller" value="true" />
874 <param name="loop" value="true" />
875 <param name="autoplay" value="false" />
876 <param name="autostart" value="false" />
877 <param name="scale" value="aspect" />
879 <object data="$url" type="$mimetype" $size>
880 <param name="src" value="$url" />
881 <param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
882 <param name="controller" value="true" />
883 <param name="loop" value="true" />
884 <param name="autoplay" value="false" />
885 <param name="autostart" value="false" />
886 <param name="scale" value="aspect" />