mediawiki中插入视频

2021/4/17 10:25:32

本文主要是介绍mediawiki中插入视频,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

第一步:在  ../mediawiki/extensions/  目录下新建文件夹  VideoPlayer。

 

第二步:在  VideoPlayer  文件里新建  VideoPlayer.php  文件,并写入以下代码:

 1 <?php
 2 // See http://www.mediawiki.org/wiki/Extension:VideoPlayer for more information.
 3 $wgExtensionFunctions[] = 'VideoPlayer';
 4 $wgExtensionCredits['parserhook'][] = array(
 5     'name'            => 'VideoPlayer',
 6     'description'    => 'Display video players for youtube, dailymotion, vimeo, google, etc...',
 7     'author'        => 'Joachim Chauveheid',
 8     'version'        => 1.0 
 9 );
10 
11 function VideoPlayer() {
12     global $wgParser;
13     $wgParser->setHook('video', 'renderVideoPlayer');
14 }
15 
16 function renderVideoPlayer($input, $args) {
17     $url = array();
18     $url['allocine']    = 'http://www.allocine.fr/blogvision/%1$s';
19     $url['blip']         = 'http://blip.tv/play/%1$s';
20     $url['dailymotion']    = 'http://www.dailymotion.com/swf/%1$s?syndication=112040';
21     $url['facebook']    = 'http://www.facebook.com/v/%1$';
22     $url['gametrailers']= 'http://www.gametrailers.com/remote_wrap.php?mid=%$1s';
23     $url['googlevideo']    = 'http://video.google.com/googleplayer.swf?docId=%1$d';
24     $url['html5'  ]        = '%1$s';
25     $url['metacafe']    = 'http://www.metacafe.com/fplayer/%1$d/' . (isset($args['vid']) ? $args['vid'] : '') . '.swf';
26     $url['myspace']        = 'http://mediaservices.myspace.com/services/media/embed.aspx/m=%1$s';
27     $url['revver']        = 'http://flash.revver.com/player/1.0/player.swf?mediaId=%1$u';
28     $url['sevenload']    = 'http://en.sevenload.com/pl/%1$s/%2$ux%3$u/swf';
29     $url['viddler']        = 'http://www.viddler.com/player/%1$s';
30     $url['vimeo']        = 'http://www.vimeo.com/moogaloop.swf?clip_id=%1$d&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0';
31     $url['youku']        = 'http://player.youku.com/player.php/sid/%1$s/.swf';
32     $url['youtube']        = 'http://www.youtube.com/v/%1$s?fs=%5$u';
33     $flashvars = array();
34     $flashvars['revver'] = 'mediaId=%1$u&affiliateId=0';
35     $type       = isset($args['type'],$url[$args['type']]) ? $args['type'] : 'youtube';
36     $media_url  = isset($url[$type]) ? $url[$type] : $url['youtube'];
37     $flash_vars = isset($flashvars[$type]) ? $flashvars[$type] : '';
38     $input_array = explode('|', htmlspecialchars($input));
39     $id     = current($input_array);
40     $width  = (count($input_array) > 1 && is_numeric($input_array[1])) ? $input_array[1] : 425;
41     $height = (count($input_array) > 2 && is_numeric($input_array[2])) ? $input_array[2] : 350;
42     $fullscreen = (isset($args['fullscreen']) ? $args['fullscreen'] : 'true') === 'false' ? false : true;
43     if(strtolower($type) == 'html5')
44     {
45         $output = '<video src="'.$id.'" controls style="width:'.$width.'px;height:'.$height.'px"></video><p style="font-size:80%;padding:0;margin:0;">(Right click to control movie)</p>';
46         return $output;
47     }
48     else
49     {
50         $output = '<object width="%2$u" height="%3$u">'
51                 .' <param name="movie" value="'.$url[$type].'" />'
52                 .' <param name="allowFullScreen" value="%4$s" />'
53                 .' <param name="wmode" value="transparent" />'
54                 .' <embed src="'.$url[$type] . '" type="application/x-shockwave-flash" wmode="transparent"'
55                 .' width="%2$u" height="%3$u" allowfullscreen="%4$s"'
56                         . ' flashvars="' . $flash_vars . '"></embed></object>';
57         return sprintf($output,$id,$width,$height,$fullscreen ? 'true' : 'false', (integer)$fullscreen);
58     }
59 }

 

第三步:在  ../mediawiki/LocalSettings.php  文件里末尾添加:

require_once("$IP/extensions/VideoPlayer/VideoPlayer.php");

 

第四步:在网页中合适位置添加:

// type为视频类型,可选择html5、facebook、youku、youtube等,中间为文件路径,最后为视频像素的参数设置。其中视频类型可能还会用到其他插件,再进行相应下载及配置。
<video type="html5">https://www.smartlegalcontract.cn/mediawiki/images/3/37/Smartcontract.mp4|500|282</video>

 

参考网页:https://www.mediawiki.org/wiki/Extension:VideoPlayer



这篇关于mediawiki中插入视频的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程