扩展:嵌入式视频

This page is a translated version of the page Extension:EmbedVideo and the translation is 75% complete.
A maintained fork of this extension is available, which focuses on privacy. Note, however, that only a subset of services is supported.
MediaWiki扩展手册
EmbedVideo
发行状态: 不再維護
实现 解析器函数
描述 添加一个名为 #ev 的分析器函数,用于嵌入来自流行视频共享服务的视频剪辑
作者
最新版本 3.4.0 (2020-10-14)
MediaWiki 1.29+
PHP 7.0+
Composer starcitizenwiki/embedvideo
许可协议 MIT授權條款
下載
示例 Gamepedia Help Wiki
  • $wgEmbedVideoEnableVideoHandler
  • $wgFFProbeLocation
  • $wgEmbedVideoUseEmbedStyleForLocalVideos
  • $wgEmbedVideoEnableAudioHandler
  • $wgEmbedVideoLazyLoadLocalVideos
  • $wgEmbedVideoRequireConsent
  • $wgEmbedVideoAddFileExtensions
  • $wgEmbedVideoShowPrivacyNotice
  • $wgEmbedVideoMaxWidth
  • $wgEmbedVideoFetchExternalThumbnails
  • $wgEmbedVideoMinWidth
  • $wgEmbedVideoDefaultWidth
  • $wgEmbedVideoEnabledServices
正在使用的公开wiki数 7,623 (Ranked 21st)
翻译EmbedVideo扩展
Vagrant角色 embedvideo

EmbedVideo 扩展添加了一个名为 #ev 的解析器函数,用于嵌入来自多种语言和国家/地区的超过 24 种流行视频共享服务的视频剪辑。 它还添加了视频和音频媒体处理程序,以支持将标准的 [[File:Example.mp4]] 文件链接转换为嵌入式 HTML5 ‎<video>‎<audio> 标记。

项目首页
GitLab上的文档
源代码
在GitLab上的源代码
程序错误
GitLab 的问题
许可协议
EmbedVideo在The MIT License下发布。
As of the 2.x series the EmbedVideo extension has a new maintainer and an entirely rewritten code base. It retains backwards compatibility with EmbedVideo 1.0 and EmbedVideoPlus.


用法

媒体处理程序

对于本地上传的内容,将其显示在页面上的过程与图像相同。 See the image syntax documentation for complete reference on this feature.

This example would display a video in page using a HTML5 ‎<video> tag.

[[File:Example.mp4]]

To specify the start and end timestamps in the media use the start and end parameters. The timestamp can be formatted as one of: ss, :ss, mm:ss, hh:mm:ss, or dd:hh:mm:ss.

[[File:Example.mp4|start=2|end=6]]

标签

The EmbedVideo parser function expects to be called in any of the following ways:

<span id="#ev_—_Classic_parser_tag">

#ev — 经典解析器标签

  • {{#ev:service|id}}
  • {{#ev:service|id|dimensions}}
  • {{#ev:service|id|dimensions|alignment}}
  • {{#ev:service|id|dimensions|alignment|description}}
  • {{#ev:service|id|dimensions|alignment|description|container}}
  • {{#ev:service|id|dimensions|alignment|description|container|urlargs}}
  • {{#ev:service|id|dimensions|alignment|description|container|urlargs|autoresize}}
  • {{#ev:service|id|dimensions|alignment|description|container|urlargs|autoresize|valignment}}

However, if needed optional arguments may be left blank by not putting anything between the pipes:

  • {{#ev:service|id|||description}}

<span id="#evt_—_Parser_tag_for_templates">

#evt — 模板的解析器标签

The #evt parser tag allows for key=value pairs which allows for easier templating and readability.

{{#evt:
service=youtube
|id=https://www.youtube.com/watch?v=eAORm-8b1Eg
|alignment=right
}}

<span id="#evu_—_Parser_tag_for_URLs">

#evu — URL 的解析器标记

The #evu parser tag is like the #evt tag, but its first parameter is a URL that will be parsed to determine the service automatically.

{{#evu:https://www.youtube.com/watch?v=eAORm-8b1Eg
|alignment=right
}}

<span id="‎<embedvideo>_—_Tag_hook">

‎<embedvideo> — 标签钩子

视频可以用‎<embedvideo>...‎</embedvideo>的标签钩子轻松嵌入。 ID/URL作为标记之间的输入,参数可以作为标记参数添加。

<embedvideo service="youtube">https://www.youtube.com/watch?v=eAORm-8b1Eg</embedvideo>

或者,您也可以使用服务id作为标记(假设另一个扩展尚未使用此标记)。

<youtube>https://www.youtube.com/watch?v=eAORm-8b1Eg</youtube>

解析器标记的属性

属性 描述 必需? 默认
service="(请参阅下面的支持服务。)" 要呼叫的视频服务。 Required
id="[id|url]" 播放器页面中的视频或网址的原始 ID。 Required
dimensions="[WIDTH|WIDTHxHEIGHT|xHEIGHT]" 用于调整嵌入容器大小的尺寸(以像素为单位)。 标准格式是宽度 x 高度,其中任何一个都可以省略,但 x 必须继续高度以将其指示为高度。

示例:480、​480x320、​x320 如果未提供高度,将根据宽度和服务默认比率自动计算。

Some services such as Gfycat do not have standard heights and should be specified for each embed. $wgEmbedVideoDefaultWidth 可以设置为 LocalSettings.php 以覆盖默认宽度。

Optional 640
alignment="[left|center|right|inline]" 将视频的位置向左、居中或向右对齐。 内联将允许多个视频并排显示,而无需强制换行。 Optional
description="[wikitext]" 在嵌入容器下显示说明。 对于换行符,请使用 &#10;(请参阅 https://www.w3.org/TR/REC-xml/#AVNormalize) Optional
container="[frame]" 指定要用于嵌入的容器类型。
frame — 将视频播放器包装在Mediawiki缩略图框中。
Optional
urlargs="modestbranding=1&version=3" 允许将额外的 URL 参数追加到生成的嵌入 URL。 这对于仅在一个服务上支持的模糊选项很有用。 Optional
autoresize="false" 当视频的大小会导致视频超出其容器元素时,自动调整视频大小。 Optional true
valignment="[top|middle|bottom|baseline]" 将视频的垂直位置与父元素的顶部、中间、底部或基线对齐。 使用此参数强制对齐参数为内联。 Optional

示例

 
例如:#1

例如,来自 YouTube 的视频使用 youtube 服务选择器。 您可以指定原始 ID:

{{#ev:youtube|eAORm-8b1Eg}}

或者指定完整的网址:

{{#ev:youtube|https://www.youtube.com/watch?v=eAORm-8b1Eg}}

要将同一视频显示为右对齐的大缩略图,并附有说明,请执行以下操作:

{{#ev:youtube|https://www.youtube.com/watch?v=eAORm-8b1Eg|1000|right|Let eet GO|frame}}

要让视频在特定时间代码开始,请使用 urlargs(网址参数)参数。 从自定义 URL 中获取其余的 URL 参数,并将它们放入 urlargs 中。 请注意,并非所有视频服务都支持额外的网址参数,或者其网址参数可能有不同的键。

https://www.youtube.com/watch?v=eAORm-8b1Eg&start=76
{{#ev:youtube|https://www.youtube.com/watch?v=pSsYTj9kCHE|||||start=76}}

URL 参数可用于剪切视频并循环播放:

https://www.youtube.com/watch?v=eAORm-8b1Eg&start=160&end=180&loop=1
{{#ev:youtube|https://www.youtube.com/watch?v=eAORm-8b1Eg|||||start=160&end=180&loop=1}}

视频标签的支持

自版本 2.5 起,添加了对未维护的视频标签扩展程序标签的支持。

从原始扩展文档中:

视频链接扩展允许在文章中嵌入YouTube视频;允许在单个嵌入式视频播放器中播放多个链接的视频,当用户单击视频链接时首次显示。

‎<vplayer /> 指定播放器应在页面中出现的位置,{{#vlink}} 解析器函数允许创建加载特定视频的链接。

<span id="‎<evlplayer>_—_Tag_hook_for_video_container">

‎<evlplayer> — 视频容器的标签钩子

为了向后兼容,这里也可以使用 ‎<vplayer> 标记。

‎<evlplayer> 标记用于在页面中定位视频播放器容器。

<evlplayer id="player id" w="width" h="height" class="class" style="style">默认路径</evlplayer>

默认情况下,可以将默认视频设置为填充容器,而不是默认路径

<evlplayer id="player1" w="480" h="360" service="youtube" defaultid="eAORm-8b1Eg" />
属性 必要的 默认 描述
id Optional default 此容器的可选唯一标识符。
w Optional 800 生成嵌入式播放器时要发送到该播放器的宽度。
h Optional 从宽度实现 16:9 Height to send to the embedded player when it's generated.
class Optional Additional CSS class to add to the container ‎<div>.
style Optional Additional in-line CSS to apply to the container ‎<div>.
defaultid Optional Video ID of default video, if you want a default video.
service Optional Service of default video, if you want a default video.

An important caveat to make note of, is that the w and h attributes only effect the video that is being included into the container ‎<div>, and not the actual container. For styling of the container, please use the class or style attributes.

The use of the {{#vlink}} parser function is also acceptable here for backwards compatibility.
{{#evl:<视频ID>|<链接文本>|<要播放的视频>|service=youtube|player=<player id>}}

In addition to all of the attributes supported by the #evt tag, these specific attributes apply to the #evl (and #vlink) tags. To maintain backwards compatibility, if you do not define a service then youtube is assumed.

属性 必要的 默认 描述
视频ID Required The ID of the video you would like to play or a comma separated list of videos to play. Please note that the use of multiple video IDs separated by a semicolon is now deprecated.
链接文字 Required 要在链接内显示的文本。
要播放的视频 Optional The number that represents the video to play from video ID if it is a comma separated list of IDs.
player id Optional default 用于加载视频的播放器容器。 Note that the ID default will only exist if you’ve defined a player with no ID.
initial video 已弃用 在原始视频链接中,这将定义在定义多个视频时首先播放的视频。 Please see notes about in video id and start.
开始 已弃用 0:00 In the original VideoLink, this defined the start time of a video. Since we support multiple video services, this feature can now be replicated with the urlargs parameter. For backwards compatibility, this attribute will be respect on videos with the service youtube.

视频链接示例

Creating a video list allows video links to create a playlist on the fly using the youtube and youtubevideolist service.

Even if you define a service the system will use youtube if a list of videos is provided.
<evlplayer w="width" h="height" class="class" style="style" id="example-player">默认路径</evlplayer>
{{#evl:21X5lGlDOfg|NASA Live|1|player=example-player}}
{{#evl:lEyCq2KRZik|IIS Q&A|2|player=example-player}}
{{#evl:OLeWbRdW6rY|Space Station Tour|3|player=example-player}}


支持的服务

从版本 2.x 开始,EmbedVideo 支持从以下服务嵌入视频内容:

站点 服务名称 ID example 网址示例 备注
Archive.org 视频 archiveorg electricsheep-flock-244-80000-6 https://archive.org/embed/electricsheep-flock-244-80000-6
Bambuser bambuser 5262334 http://bambuser.com/v/5262334 广播
bambuser_channel 频道
Beam beam RocketBear https://beam.pro/RocketBear
Bing bing 31ncp9r7l http://www.bing.com/videos/watch/video/adorable-cats-attempt-to-eat-invisible-tuna/31ncp9r7l
Blip.tv blip http://blip.tv/vinylrewind/review-6864612 Blip 需要视频页面的完整 URL,并且不接受原始 ID。
C3TV mediacccde 32c3-7305-quantum_cryptography https://media.ccc.de/v/32c3-7305-quantum_cryptography
CollegeHumor collegehumor 6875289 http://www.collegehumor.com/video/6875289/batman-says-his-goodbyes
Dailymotion dailymotion x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms http://www.dailymotion.com/video/x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms
Daum TVPot tvpotObtain the URL or ID from the share menu URL. s9011HdLzYwpLwBodQzCHRB http://tvpot.daum.net/v/s9011HdLzYwpLwBodQzCHRB
Div Share divshare
Edutopia Edutopia content moved to YouTube. Please use the YouTube service selector below.
FunnyOrDie funnyordie c61fb67ac9 http://www.funnyordie.com/videos/c61fb67ac9/to-catch-a-predator-elastic-heart-edition
Gfycat gfycat BruisedSilentAntarcticfurseal http://www.gfycat.com/BruisedSilentAntarcticfurseal
Hitbox hitbox Washuu http://www.hitbox.tv/Washuu
JW Player jwplayer cr5d8nbu-8ZpoNmmJ https://content.jwplatform.com/players/cr5d8nbu-8ZpoNmmJ.html
Kickstarter kickstarter elanlee/exploding-kittens https://www.kickstarter.com/projects/elanlee/exploding-kittens
Metacafe metacafe 11404579 http://www.metacafe.com/watch/11404579/lan_party_far_cry_4/
Nico Nico Video nico sm24394325 http://www.nicovideo.jp/watch/sm24394325
RuTube rutube b698163ccb67498db74d50cb0f22e556 http://rutube.ru/video/b698163ccb67498db74d50cb0f22e556/
SoundCloud soundcloud https://soundcloud.com/skrillex/skrillex-rick-ross-purple-lamborghini SoundCloud需要完整的URL。
TeacherTube teachertube 370511 http://www.teachertube.com/video/thats-a-noun-sing-along-hd-version-370511
TED Talks ted bruce_aylward_humanity_vs_ebola_the_winning_strategies_in_a_terrifying_war http://www.ted.com/talks/bruce_aylward_humanity_vs_ebola_the_winning_strategies_in_a_terrifying_war
Tubi TV tubitv 318409 http://tubitv.com/video/318409
Tudou tudou mfQXfumwiew http://www.tudou.com/listplay/mfQXfumwiew.html
Twitch twitch twitchplayspokemon http://www.twitch.tv/twitchplayspokemon 实况流
twitchvod Archived Videos on Demand
Videomaten videomaten
Vimeo vimeo 105035718 http://vimeo.com/105035718
Vine vine h2B7WMtuX2t https://vine.co/v/h2B7WMtuX2t
Yahoo Screen (Archived 2013-09-20 at the Wayback Machine) yahoo katy-perry-dances-sharks-2015-024409668 https://screen.yahoo.com/videos-for-you/katy-perry-dances-sharks-2015-024409668.html
YouTube youtube pSsYTj9kCHE https://www.youtube.com/watch?v=pSsYTj9kCHE 单个视频
youtubeplaylist https://www.youtube.com/watch?v=CW_PbErQ_c8&list=PL76E80C7F756A2047 播放列表
youtubevideolist https://www.youtube.com/watch?v=CW_PbErQ_c8&playlist=CW_PbErQ_c8,CW_PbErQ_c8 视频列表
Youku youku XODc3NDgzMTY4 http://v.youku.com/v_show/id_XODc3NDgzMTY4.html

安裝

配置

变量 默认值 类型 描述
$wgEmbedVideoAddFileExtensions true 布尔值 启用或禁用将视频/音频文件扩展名添加到允许上传的文件列表中。
$wgEmbedVideoEnableVideoHandler true 布尔值 启用或禁用用于在文章中显示嵌入视频的视频媒体处理程序。
$wgEmbedVideoEnableAudioHandler true 布尔值 Enable or disable the audio media handlers for displaying embedded audio in articles.
$wgEmbedVideoDefaultWidth '' 整数 Globally override the default width of video players. When not set this uses the video service's default width which is typically 640 pixels.
$wgEmbedVideoMinWidth '' 整数 Minimum width of video players. Widths specified below this value will be automatically bounded to it.
$wgEmbedVideoMaxWidth '' 整数 视频播放器的最大宽度。 在此值上方指定的宽度将自动绑定到该值。
$wgFFmpegLocation '/usr/bin/ffmpeg' 字符串 设置 ffmpeg 二进制文件的位置。
$wgFFprobeLocation '/usr/bin/ffprobe' 字符串 设置 ffprobe 二进制文件的位置。

版本历史

v2.9.0
  • Fix stored XSS in AudioTransformOutput and VideoTransformOutput.
  • Fix autoResize on mobile.
  • Fix video caption escaping the container.
  • Handle multiple video sizes per page in resize.
  • Move beam service to mixer.
  • Add a default link title for #evl/#vlink.
  • Add spotify playlist embeds.
  • Add facebook video embeds.
  • Fix centering of videos.
  • Add Microsoft Stream service.
  • Add title to iframes.
  • Add API help messages for 1.33 compatibility.
  • Fix static analysis issues.
  • Fix Twitch embeds.
v2.8.0
  • Renamed hitbox.tv to smashcast.tv.
  • Updated Nico Video embed code.
  • Added support for Twitch clips.
  • Fix issues with Twitch VODs.
  • Removed unused $wgFFmpegLocation that was interferring with TimedMediaHandler.
  • Added Polish translation.
v2.7.4
  • Added support for playlist to evlplayer
  • Added support for youtube video list
  • Updated Documentation for evlplayer
  • Added missing dependency for evlplayer in extension.json
v2.7.3
  • Default Twitch VOD to autoplay=false by default
  • Allow videos to be sized in 1:1 aspect ratios for special use cases.
v2.7.2
  • Added feature to evlplayer to allow default video content
v2.7.1
  • Fixed issue with youku videos not embedding properly on https enabled wikis.
v2.7.0
  • Added SoundCloud support
  • Added ability to use service name as a parser tag (if not defined previously)
v2.6.1

发行说明

使用解析器函数作为视频剪辑的注入机制(与扩展标记相对)的主要好处是解析器函数可以利用模板参数(形式为 {{{1}}})。 例如,假设您发现自己制作了许多缩略图大小的YouTube视频,像图像一样右对齐。 您可以创建一个名为 Template:Youtube_tn 的模板,其中可能包含以下内容:

<div class="thumb tright">
{{#ev:youtube|{{{1}}}|{{{2|100}}}}}
</div>

然后这样称呼它:

{{youtube tn|someYoutubeId}}

报告问题

There is an issue tracker set up on the GitLab project page.

贡献

欢迎错误报告、功能请求和补丁。 New contributors can be added to the GitLab project if there is sufficient interest.

参见

网页链接

參考