Template:EmbedVideo: Difference between revisions

Jump to navigation Jump to search
(Update doc for 2.x version)
(Undo revision 116066 by Kolano (talk))
Line 1: Line 1:
The '''EmbedVideo''' Extension is a MediaWiki extension which adds a parser function called <tt>#ev</tt> for embedding video clips from over 24 popular video sharing services in multiple languages and countries.
<includeonly><!---
-->{{#vardefine:vg_used|yes}}{{#vardefine:servicename|{{#switch:{{{1}}}
|dailymotion=Dailymotion
|divshare=DivShare
|googlevideo=Google Video
|interia=Interia
|youtube=YouTube
|vimeo=Vimeo
}}}}<!---


==Usage==
-->{{#vardefine:templatename|{{#switch:{{{1}}}
=== Tags ===
|dailymotion=Dailymotion
The EmbedVideo parser function expects to be called in any of the following ways:
|divshare=DivShare
|googlevideo=GoogleVideo
|interia=Interia
|youtube=YouTube
|vimeo=Vimeo
}}}}<!---


====#ev - Classic Parser Tag====
-->{{#vardefine:serviceurl|{{#switch:{{{1}}}
* <code><nowiki>{{#ev:service|id}}</nowiki></code>
|dailymotion=<nowiki>http://www.dailymotion.com/video/</nowiki>
* <code><nowiki>{{#ev:service|id|dimensions}}</nowiki></code>
|divshare=<nowiki>http://www.divshare.com/download/</nowiki>
* <code><nowiki>{{#ev:service|id|dimensions|alignment}}</nowiki></code>
|googlevideo=<nowiki>http://video.google.com/videoplay?docid=</nowiki>
* <code><nowiki>{{#ev:service|id|dimensions|alignment|description}}</nowiki></code>
|interia=<nowiki>http://video.interia.pl/obejrzyj,film,</nowiki>
* <code><nowiki>{{#ev:service|id|dimensions|alignment|description|container}}</nowiki></code>
|youtube=<nowiki>http://www.youtube.com/watch?v=</nowiki>
* <code><nowiki>{{#ev:service|id|dimensions|alignment|description|container|urlargs}}</nowiki></code>
|vimeo=<nowiki>http://vimeo.com/</nowiki>
}}}}<!---


However, if needed optional arguments may be left blank by not putting anything between the pipes:
-->{{#vardefine:videoid|{{#switch:{{{1}}}
* <code><nowiki>{{#ev:service|id|||description}}</nowiki></code>
|dailymotion=x1k3syf_dakar-2-hd-on-dolphin-emulator-part2_videogames
|divshare=13956887-4c7
|googlevideo=163776723883589087
|interia=102988
|youtube=VqNcksMfAjM
|vimeo=13118504
}}}}<!---


====#evt - Parser Tag for Templates====
-->{{#vardefine:videocaption|{{#switch:{{{1}}}
The <nowiki>#evt</nowiki> parser tag allows for key=value pairs which allows for easier templating and readability.
|dailymotion=Dakar 2 HD on Dolphin
|divshare=It_s_A_Wonderful_World.mp4
|googlevideo=Paper Mario Speed run part 1
|interia=Na święta!!! Nintendo Wii
|youtube=The Legend of Zelda: The Wind Waker Intro
|vimeo=Super Mario Bros.
}}}}<!---


<pre><nowiki>{{#evt:
-->This template provides a simplified way to use the [[Template:EmbedVideo|EmbedVideo]] plugin. It automatically uses the standard thumbnail size and position used on this wiki.
service=youtube
|id=https://www.youtube.com/watch?v=pSsYTj9kCHE
|alignment=right
}}</nowiki></pre>


====<nowiki><embedvideo></nowiki> - Tag Hook====
== Usage ==
Videos can easily be embedded with the <nowiki><embedvideo></embedvideo></nowiki> tag hook. The ID/URL goes as the input between the tags and parameters can be added as the tag arguments.
The {{#var:servicename}} template should be called in the following way:
*<code><nowiki>{{</nowiki>{{#var:templatename}}<nowiki>|<videoID>|<title>|<options>}}</nowiki></code>
where
*<code>Video ID</code> is the ID is the bold part of the URL ({{#var:serviceurl}}'''{{#var:videoid}}''')
*<code>Title</code> (optional) is the caption for the video
*<code>options</code> (optional) control some other functionalities of this template. Specifying <code>br</code> in this parameter tell the template to create a new row after embedding the video. Specifying <code>link</code> makes the template return only a hiperlink to watch the video on {{#var:servicename}}.


<pre><nowiki><embedvideo service="youtube">https://www.youtube.com/watch?v=pSsYTj9kCHE</embedvideo></nowiki></pre>
== Examples ==
* Embed a video by specifying video ID and title. Titles longer than the box will automatically be truncated. We are embedding only one video, so we should add the <code>br</code> tag to the 3rd parameter. In this example, <code><nowiki>{{</nowiki>{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}} with caption text longer than thumbnail box size<nowiki>|br}}</nowiki></code> will produce this:
{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}} with caption text longer than thumbnail box size|br}}


=== Attributes for Parser Tags ===
* Embed a video by specifying only video ID, so the 2nd parameter is null. We are embedding only one video, so we should add the <code>br</code> tag to the 3rd parameter. In this example, <code><nowiki>{{</nowiki>{{#var:templatename}}|{{#var:videoid}}<nowiki>||br}}</nowiki></code> make the template use URL as title since no title was entered:
{| class="wikitable"
{{{{#var:templatename}}|{{#var:videoid}}||br}}
|-
! Attribute
! Description
|-
| <code>service="<nowiki>(See Supported Services below.)</nowiki>"</code>
| '''Required:''' yes
:The video service to call.
|-
| <code>id="<nowiki>[id|url]</nowiki>"</code>
| '''Required:''' yes
:The raw ID of the video or URL from the player page.
|-
| <code>dimensions="<nowiki>[WIDTH|WIDTHxHEIGHT|xHEIGHT]</nowiki>"</code>
| '''Required:''' no, '''Default:''' <tt>640</tt>
:Dimensions in pixels to size the embed container.  The standard format is width x height where either can be omitted, but the <tt>x</tt> must proceed height to indicate it as the height.
:Examples: <tt>480</tt>, <tt>480x320</tt>, <tt>x320</tt>.  If the height is not provided it will be calculated automatically from the width and service default ratio.
:Some services such as ''Gfycat'' do not have standard heights and should be specified for each embed.  <tt>$wgEmbedVideoDefaultWidth</tt> can be set in <tt>LocalSettings.php</tt> to override the default width.
|-
| <code>alignment="<nowiki>[left|center|right]</nowiki>"</code>
| '''Required:''' no, '''Default:''' <tt>none</tt>
:Align the placement of the video either to the left, centered, or to the right.
|-
| <code>description="<nowiki>[wiki text]</nowiki>"</code>
| '''Required:''' no, '''Default:''' <tt>none</tt>
:Display a description under the embed container.
|-
| <code>container="<nowiki>[frame]</nowiki>"</code>
| '''Required:''' no, '''Default:''' <tt>none</tt>
:Specifies the container type to use for the embed.
::<tt>frame</tt>: Wrap the video player in a Mediawiki thumbnail box.
|-
| <code>urlargs="<nowiki>modestbranding=1&version=3</nowiki>"</code>
| '''Required:''' no, '''Default:''' <tt>none</tt>
:Allows extra URL arguments to be appended to the generated embed URL.  This is useful for obscure options only supported on one service.
|}


=== Examples ===
* Return a hiperlink to watch the video on {{#var:servicename}} by specifying video ID and title. We want only the hiperlink, so we should add the <code>link</code> tag to the 3rd parameter. In this example, <code><nowiki>{{</nowiki>{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}<nowiki>|link}}</nowiki></code> will produce this:
For example, a video from YouTube use the 'youtube' service selector enter either the raw ID:
:{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}|link}}
<pre>{{#ev:youtube|pSsYTj9kCHE}}</pre>
Or the full URL:
<pre>{{#ev:youtube|https://www.youtube.com/watch?v=pSsYTj9kCHE}}</pre>


To display the same video as a right aligned large thumbnail with a description:
* Return a hiperlink to watch the video on {{#var:servicename}} by specifying only video ID. We want only the hiperlink, so we should add the <code>link</code> tag to the 3rd parameter. In this example, <code><nowiki>{{</nowiki>{{#var:templatename}}|{{#var:videoid}}<nowiki>||link}}</nowiki></code> make the template use URL as title since no title was entered:
<pre>{{#ev:youtube|https://www.youtube.com/watch?v=pSsYTj9kCHE|1000|right|Let eet GO|frame}}</pre>
:{{{{#var:templatename}}|{{#var:videoid}}||link}}


For YouTube to have the video start at a specific time code utilize the urlargs(URL arguments) parameter. Take the rest of the URL arguments from the custom URL and place them into the urlargs.  Please note that not all video services support extra URL arguments or may have different keys for their URL arguments.
== Notes ==
<pre>https://www.youtube.com/watch?v=pSsYTj9kCHE&start=76</pre>
* To use only video ID and an option, you must null the 2nd parameter by using ||, like this: <code><nowiki>{{</nowiki>{{#var:templatename}}<nowiki>|<videoID>||<options>}}</nowiki></code>
<pre>{{#ev:youtube|https://www.youtube.com/watch?v=pSsYTj9kCHE|||||start=76}}</pre>
* The 3rd parameter only accept one option. If you include more than one option, none of them will work.
* Using multiple calls will make the videos be side-by-side (the last video should ALWAYS include the <code>br</code> tag to the 3rd parameter):
{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}}}
{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}}}
{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}|br}}


=== Supported Services ===
* When you need one video in each row, you should add the <code>br</code> tag to the 3rd parameter of all videos, not just the last:
As of version 2.x, EmbedVideo supports embedding video content from the following services:
{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}|br}}
{| class="wikitable"
{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}|br}}
|-
{{{{#var:templatename}}|{{#var:videoid}}|{{#var:videocaption}}}}
! Site
 
! colspan="2"|Service Name(s)
* If you use this template and forget to add the <code>br</code> tag to the 3rd parameter after calling the last video, you'll get something weird, like this topic!</includeonly><noinclude>
! ID Example
{{documentation}}</noinclude>
! URL Example(s)
|-
! [https://archive.org/details/movies Archive.org Videos]
| colspan="2"|<tt>archiveorg</tt>
| <nowiki>electricsheep-flock-244-80000-6</nowiki>
| <nowiki>https://archive.org/details/electricsheep-flock-244-80000-6</nowiki>
  <nowiki>https://archive.org/embed/electricsheep-flock-244-80000-6</nowiki>
|-
! [http://bambuser.com/ Bambuser]
| <tt>bambuser</tt> - Broadcasts
| <tt>bambuser_channel</tt> - Channels
| <nowiki>5262334</nowiki>
| <nowiki>http://bambuser.com/v/5262334</nowiki>
|-
! [https://beam.pro/ Beam]
| colspan="2"|<tt>beam</tt> - Streams
| <nowiki>RocketBear</nowiki>
| <nowiki>https://beam.pro/RocketBear</nowiki>
|-
! [http://www.bing.com/videos/ Bing]
| colspan="2"|<tt>bing</tt>
| <nowiki>31ncp9r7l</nowiki>
| <nowiki>http://www.bing.com/videos/watch/video/adorable-cats-attempt-to-eat-invisible-tuna/31ncp9r7l</nowiki>
|-
! [http://www.blip.tv/ Blip.tv]
| colspan="2"|<tt>blip</tt> - Blip requires the full URL to the video page and does not accept the raw ID.
|  
|<nowiki>http://blip.tv/vinylrewind/review-6864612</nowiki>
|-
! [http://www.collegehumor.com/ CollegeHumor]
| colspan="2"|<tt>collegehumor</tt>
| <nowiki>6875289</nowiki>
| <nowiki>http://www.collegehumor.com/video/6875289/batman-says-his-goodbyes</nowiki>
|-
! [http://www.dailymotion.com/ Dailymotion]
| colspan="2"|<tt>dailymotion</tt>
| <nowiki>x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms</nowiki>
| <nowiki>http://www.dailymotion.com/video/x1adiiw_archer-waking-up-as-h-jon-benjamin_shortfilms</nowiki>
|-
! [http://tvpot.daum.net/ Daum TVPot]
| colspan="2"|<tt>tvpot</tt> - Obtain the URL or ID from the share menu URL.
| <nowiki>s9011HdLzYwpLwBodQzCHRB</nowiki>
| <nowiki>http://tvpot.daum.net/v/s9011HdLzYwpLwBodQzCHRB</nowiki>
|-
! [http://www.divshare.com Div Share]
| colspan="2"|<tt>divshare</tt>
|
|
|-
! [http://edutopia.org Edutopia]
| colspan="2"|Edutopia content moved to YouTube.  Please use the youtube service selector below.
|
|
|-
! [http://www.funnyordie.com/ FunnyOrDie]
| colspan="2"|<tt>funnyordie</tt>
| <nowiki>c61fb67ac9</nowiki>
| <nowiki>http://www.funnyordie.com/videos/c61fb67ac9/to-catch-a-predator-elastic-heart-edition</nowiki>
|-
! [http://gfycat.com/ Gfycat]
| colspan="2"|<tt>gfycat</tt>
| <nowiki>BruisedSilentAntarcticfurseal</nowiki>
| <nowiki>http://www.gfycat.com/BruisedSilentAntarcticfurseal</nowiki>
|-
! [http://www.hitbox.tv/ Hitbox]
| colspan="2"|<tt>hitbox</tt>
| <nowiki>Washuu</nowiki>
| <nowiki>http://www.hitbox.tv/Washuu</nowiki>
|-
! [http://www.kickstarter.com/ Kickstarter]
| colspan="2"|<tt>kickstarter</tt>
| <nowiki>elanlee/exploding-kittens</nowiki>
| <nowiki>https://www.kickstarter.com/projects/elanlee/exploding-kittens</nowiki>
|-
! [http://www.metacafe.com/ Metacafe]
| colspan="2"|<tt>metacafe</tt>
| <nowiki>11404579</nowiki>
| <nowiki>http://www.metacafe.com/watch/11404579/lan_party_far_cry_4/</nowiki>
|-
! [http://www.nicovideo.jp/ Nico Nico Video]
| colspan="2"|<tt>nico</tt>
| <nowiki>sm24394325</nowiki>
| <nowiki>http://www.nicovideo.jp/watch/sm24394325</nowiki>
|-
! [http://rutube.ru/ RuTube]
| colspan="2"|<tt>rutube</tt>
| <nowiki>b698163ccb67498db74d50cb0f22e556</nowiki>
| <nowiki>http://rutube.ru/video/b698163ccb67498db74d50cb0f22e556/</nowiki>
|-
! [http://teachertube.com TeacherTube]
| colspan="2"|<tt>teachertube</tt>
| <nowiki>370511</nowiki>
| <nowiki>http://www.teachertube.com/video/thats-a-noun-sing-along-hd-version-370511</nowiki>
|-
! [http://www.ted.com/talks/browse/ TED Talks]
| colspan="2"|<tt>ted</tt>
| <nowiki>bruce_aylward_humanity_vs_ebola_the_winning_strategies_in_a_terrifying_war</nowiki>
| <nowiki>http://www.ted.com/talks/bruce_aylward_humanity_vs_ebola_the_winning_strategies_in_a_terrifying_war</nowiki>
|-
! [http://www.tudou.com/ Tudou]
| colspan="2"|<tt>tudou</tt>
| <nowiki>mfQXfumwiew</nowiki>
| <nowiki>http://www.tudou.com/listplay/mfQXfumwiew.html</nowiki>
|-
! [http://www.twitch.tv Twitch]
| <tt>twitch</tt> - Live Streams
| <tt>twitchvod</tt> - Archived Videos on Demand
| <nowiki>twitchplayspokemon</nowiki>
| <nowiki>http://www.twitch.tv/twitchplayspokemon</nowiki>
|-
! [http://89.160.51.62/recordme/spelain.htm Videomaten]
| colspan="2"|<tt>videomaten</tt>
|
|
|-
! [http://www.vimeo.com Vimeo]
| colspan="2"|<tt>vimeo</tt>
| <nowiki>105035718</nowiki>
| <nowiki>http://vimeo.com/105035718</nowiki>
|-
! [http://vine.co Vine]
| colspan="2"|<tt>vine</tt>
| <nowiki>h2B7WMtuX2t</nowiki>
| <nowiki>https://vine.co/v/h2B7WMtuX2t</nowiki>
|-
! [http://screen.yahoo.com/ Yahoo Screen]
| colspan="2"|<tt>yahoo</tt>
| <nowiki>katy-perry-dances-sharks-2015-024409668</nowiki>
| <nowiki>https://screen.yahoo.com/videos-for-you/katy-perry-dances-sharks-2015-024409668.html</nowiki>
|-
! [http://www.youtube.com/ YouTube]
| <tt>youtube</tt> - Single Videos
| <tt>youtubeplaylist</tt> - Playlists
| <nowiki>pSsYTj9kCHE</nowiki>
| <nowiki>https://www.youtube.com/watch?v=pSsYTj9kCHE</nowiki>
  <nowiki>https://www.youtube.com/watch?v=CW_PbErQ_c8&list=PL76E80C7F756A2047</nowiki>
|-
! [http://www.youku.com/ Youku]
| colspan="2"|<tt>youku</tt>
| <nowiki>XODc3NDgzMTY4</nowiki>
| <nowiki>http://v.youku.com/v_show/id_XODc3NDgzMTY4.html</nowiki>
|-
|}