YouTube (embedded) player parameters
For easy reference, YouTube Embedded Players and Player Parameters. Check the Google Developers site for the latest version: https://developers.google.com/youtube/player_parameters
Overview
This document explains how to embed a YouTube player in your application and also defines the parameters that are available in the YouTube embedded player.
YouTube players can be embedded in a web page using either an <iframe>
tag or an <object>
tag. By appending parameters to the IFrame or SWF URL, you can customize the playback experience in your application. For example, you can automatically play videos using the autoplay
parameter or cause a video to play repeatedly using the loop
parameter. You can also use the enablejsapi
parameter to enable the player to be controlled via the IFrame Player API.
This page currently defines all parameters supported in any YouTube embedded player. Each parameter definition identifies the players that support the corresponding parameter.
Note: Embedded players must have a viewport that is at least 200px by 200px. If the player displays controls, it must be large enough to fully display the controls without shrinking the viewport below the minimum size. We recommend 16:9 players be at least 480 pixels wide and 270 pixels tall.
Deprecation Notice
YouTube <object>
embeds were deprecated on January 27, 2015. Please migrate your applications to use <iframe>
embeds, which can intelligently use whichever embedded player – HTML (<video>
) or Flash (<object>
) – the client supports.
Embed a YouTube player
Best practice: IFrame embeds are the recommended method for embedding a YouTube player because the IFrame will select the appropriate player based on the client’s capabilities and available YouTube file formats.
You can use any of the following methods to embed a YouTube player in your application and specify player parameters. Note that the instructions below demonstrate how to embed a player that loads a single video. The following section explains how to configure your player to load other types of content, such as playlists and search results.
Embed a player using an <iframe>
tag
Define an <iframe>
tag in your application in which the src
URL specifies the content that the player will load as well as any other player parameters you want to set. The <iframe>
tag’s height
and width
parameters specify the dimensions of the player.
If you create the <iframe>
element yourself (rather than using the IFrame Player API to create it), you can append player parameters directly to the end of the URL. The URL has the following format:
http://www.youtube.com/embed/VIDEO_ID
The <iframe>
tag below would load a 640x390px player that would play the YouTube video M7lc1UVf-VE
. Since the URL sets the autoplay
parameter to 1
, the video would play automatically once the player has loaded.
<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com" frameborder="0"/>
Embed a player using the IFrame Player API
Follow the IFrame Player API instructions to insert a video player in your web page or application after the Player API’s JavaScript code has loaded. The second parameter in the constructor for the video player is an object that specifies player options. Within that object, the playerVars
property identifies player parameters.
The HTML and JavaScript code below shows a simple example that inserts a YouTube player into the page element that has an id
value of ytplayer
. The onYouTubePlayerAPIReady()
function specified here is called automatically when the IFrame Player API code has loaded. This code does not define any player parameters and also does not define other event handlers.
<div id="ytplayer"></div> <script> // Load the IFrame Player API code asynchronously. var tag = document.createElement('script'); tag.src = "https://www.youtube.com/player_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); // Replace the 'ytplayer' element with an <iframe> and // YouTube player after the API code downloads. var player; function onYouTubePlayerAPIReady() { player = new YT.Player('ytplayer', { height: '390', width: '640', videoId: 'M7lc1UVf-VE' }); } </script>
AS3 object embeds (DEPRECATED)
Note: YouTube <object>
embeds were deprecated on January 27, 2015. Please migrate your applications to the <iframe>
embeds, which can intelligently use whichever embedded player – HTML (<video>
) or Flash (<object>
) – the client supports.
Object embeds use an <object>
tag to specify the player’s dimensions and parameters. The sample code below demonstrates how to use an object embed to load an AS3 player that automatically plays the same video as the previous two examples.
<object width="640" height="390"> <param name="movie" value="https://www.youtube.com/v/M7lc1UVf-VE?version=3&autoplay=1"></param> <param name="allowScriptAccess" value="always"></param> <embed src="https://www.youtube.com/v/M7lc1UVf-VE?version=3&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" width="640" height="390"></embed> </object>
Select content to play
Note: YouTube <object>
embeds were deprecated on January 27, 2015. Please migrate your applications to use <iframe>
embeds, which can intelligently use whichever embedded player – HTML (<video>
) or Flash (<object>
) – the client supports.
You can configure your embedded player to load a video, a playlist, a user’s uploaded videos, or search results for a particular query. However, options other than loading a single video are only supported in AS3 object embeds and in IFrame embeds that load the AS3 player. (IFrame embeds could also load the HTML5 player.)
The following list explains these options:
- Loading a video
For an IFrame embed, the YouTube video ID for the video that you want to load is specified in the IFrame’s
src
URL. For an AS3 object embed, the video ID is specified in the player’s SWF URL.IFrame embed: https://youtube.com/watch?v=VIDEO_ID Embedded AS3 player: (DEPRECATED) https://youtube.com/watch?v=VIDEO_ID%3Fversion%3D3 Chromeless AS3 player: (DEPRECATED) http://www.youtube.com/apiplayer?video_id=VIDEO_ID&version=3
If you are using the YouTube Data API (v3), you can programmatically construct these URLs by retrieving video IDs from search results, playlist item resources, video resources, or other resources. After obtaining a video ID, replace the
VIDEO_ID
text in the URLs above with that value to create the player URL. - Loading a playlist
Set the
listType
player parameter toplaylist
. In addition, set thelist
player parameter to the YouTube playlist ID that you want to load.http://www.youtube.com/embed?listType=playlist&list=PLAYLIST_ID
Note that you need to prepend the playlist ID with the letters
PL
as shown in the following example:http://www.youtube.com/embed?listType=playlist&list=PLC77007E23FF423C6
If you are using the YouTube Data API (v3), you can programmatically construct these URLs by retrieving playlist IDs from search results, channel resources, or activity resources. After obtaining a playlist ID, replace the
PLAYLIST_ID
text in the URL above with that value. - Loading a user’s uploaded videos
Set the
listType
player parameter touser_uploads
. In addition, set thelist
player parameter to the YouTube username whose uploaded videos you want to load.http://www.youtube.com/embed?listType=user_uploads&list=USERNAME
- Loading search results for a specified query
Set the
listType
player parameter tosearch
. In addition, set thelist
player parameter to the query term for which you want the player to load search results.http://www.youtube.com/embed?listType=search&list=QUERY
Supported parameters
All of the following parameters are optional. The list shows parameters supported in any YouTube embedded player. If all players do not support a particular parameter, that parameter’s definition will identify the players that do support it. Note that these parameters are only officially supported by the embedded player, but a subset of them may also work with other players such as the playlist player.
Note: IFrame embeds can load either the HTML5 player or the AS3 player. Though some parameters are not supported in both players, an IFrame embed that loads the AS3 player will support all parameters that work with that player and ignore all other parameters. Similarly, an IFrame embed that loads the HTML5 player will support all parameters that work with that player while ignoring all other parameters.
For example, the HTML5 player does not currently support the playerapiid
parameter, but you can still specify that parameter when creating an IFrame embed. If the embed loads the AS3 player, the player will support the parameter, and if the embed loads the HTML5 player, the player will ignore it.
Parameters | |||||
---|---|---|---|---|---|
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
| ||||
|
|
Revision history
August 19, 2015
- The
autohide
parameter has been deprecated for the HTML5 player. In HTML5 players, the video progress bar and player controls display or hide automatically. That behavior corresponds to anautohide
setting of1
. - The
theme
parameter has been deprecated for the HTML5 player. HTML5 players now always use the dark theme.
March 9, 2015
- The document has been updated to reflect the fact that YouTube
<object>
embeds, the YouTube Flash Player API and the YouTube JavaScript Player API have all been deprecated as of January 27, 2015. A deprecation warning appears in several sections of this document to help point readers to the IFrame Player API as an alternative. - The definition of the
autohide
parameter has been updated to clarify the meaning of the parameter’s values. The default behavior (autohide=2
) is that if the player has a 16:9 or 4:3 aspect ratio, the player’s video progress bar and player controls display or hide automatically. Otherwise, those controls are visible throughout the video. - The definition of the
hl
parameter has been updated to note that the parameter value could be an ISO 639-1 two-letter language code or a fully specified locale. For example,fr
andfr-ca
are both valid parameter values. - The definition of the
enablejsapi
parameter has been reworded to clarify that the parameter enables a player to be controlled via API calls. The API could be either the IFrame Player API or the JavaScript Player API.
October 14, 2014
- The HTML5 player now supports the
cc_load_policy
,disablekb
,end
,fs
,list
, andlistType
parameters. The parameter descriptions have been updated accordingly.
July 18, 2014
- The new
hl
parameter can be used to set the player’s interface language. The interface language is used for tooltips in the player and also affects the default caption track. The selected caption track may also depend on the availability of caption tracks and user’s individual language preferences.The parameter’s value is an ISO 639-1 two-letter language code, though other language input codes, such as IETF language tags (BCP 47) may also be handled properly.
- The definition of the
playsinline
parameter, which only affects HTML5 players on iOS, has been modified slightly. The definition now notes that setting the parameter value to1
causes inline playback only forUIWebViews
created with theallowsInlineMediaPlayback
property set toTRUE
.
January 28, 2014
- The
playsinline
parameter controls whether videos play inline or fullscreen in an HTML5 player on iOS. Setting the value to1
causes inline playback. - The Selecting content to play section has been updated to explain how to find YouTube video IDs and playlist IDs using the YouTube Data API (v3) rather than the older API version.
- The
controls
parameter’s definition has been updated to reflect the fact that the parameter value only affects the time that the Flash player actually loads in IFrame embeds. In addition, for IFrame embeds, the parameter value also determines when the controls display in the player. If you set the parameter’s value to2
, then the controls display and the Flash player loads after the user initiates the video playback.
May 10, 2013
This update contains the following changes:
- YouTube no longer identifies experimental API features and services. Instead, we now provide a list of YouTube APIs that are subject to the deprecation policy.
July 20, 2012
This update contains the following changes:
- The definition of the
controls
parameter has been updated to reflect support for a parameter value of2
and to explain that, for AS3 players, the parameter value determines the time when the Flash player actually loads. If thecontrols
parameter is set to0
or1
, the Flash player loads immediately. If the parameter value is2
, the Flash player does not load until the video playback is initiated.
June 5, 2012
This update contains the following changes:
- The HTML5 player now supports the
color
,modestbranding
, andrel
parameters, and the definitions for these parameters have been updated accordingly. - The definition of the
showinfo
parameter has been updated to explain how that if the player is loading a playlist, and you explicitly set the parameter value to1
, then, upon loading, the player will also display thumbnail images for the videos in the playlist. Note that this functionality is only supported for the AS3 player since that is the only player that can load a playlist.
May 4, 2012
This update contains the following changes:
- The
showinfo
parameter’s definition has been updated to reflect the fact that the HTML5 player supports this parameter.
May 3, 2012
This update contains the following changes:
- The new
end
parameter specifies the time, measured in seconds from the start of the video, when the player should stop playing a video. Note that the time when playback is stopped is measured from the beginning of the video and not from the value of either thestart
player parameter or thestartSeconds
parameter, which is used in YouTube Player API functions for loading or queueing a video.
March 29, 2012
This update contains the following changes:
- The new Embedding a YouTube player section explains different ways to embed a YouTube player in your application. This section covers manual IFrame embeds, IFrame embeds that use the IFrame Player API, and AS3 and AS2 object embeds. This section incorporates information from the old Example usage section, which has been removed.
- The new Selecting content to play section explains how to configure the player to load a video, a playlist, search results for a specified query, or uploaded videos for a specified user.
- The new
list
andlistType
parameters let you specify the content that the player should load. You can specify a playlist, a search query, or a particular user’s uploaded videos. - The definitions of the
fs
andrel
parameters have been updated to more clearly explain the default parameter values for the AS3 player. - The
border
,color1
,egm
,hd
, andshowsearch
parameters, which are all only supported for the deprecated AS2 Player API, have been moved to a new section named deprecated parameters only used in the AS2 Player API. - The document no longer provides a way to filter the parameter list to only display parameters supported in either the AS3, AS2, or HTML5 player. Instead, each parameter definition has been updated to identify the players that support that parameter.
August 11, 2011
This update contains the following changes:
- The new
theme
andcolor
parameters let you customize the appearance of the embedded player’s player controls. See the YouTube API blog for more information.
June 8, 2011
This update contains the following changes:
- The new
modestbranding
parameter lets you use a YouTube player that does not show a YouTube logo. As of this release, the parameter was only supported for the AS3 embedded player and for IFrame embeds that loaded the AS3 player. As of June 5, 2012, the HTML5 player also supported this parameter.
February 14, 2011
This update contains the following changes:
- The documentation has been updated to note that the AS2 Player API has been deprecated. The deprecation of the AS2 Player API was actually announced on October 14, 2009.
February 3, 2011
This update contains the following changes:
- The documentation has been updated to identify parameters supported in the HTML5 (IFrame) embedded player.
- The document now displays all of the parameters supported in any of YouTube’s embedded players (HTML5, AS3, AS2).
- The following parameters are supported in the AS2 player but have been deprecated for the newer AS3 and HTML5 players:
border
,color1
,color2
,egm
,hd
, andshowsearch
.In addition, the
loop
parameter has limited support in the AS3 player and in IFrame embeds, which could load either an AS3 or HTML player. Currently, theloop
parameter only works in the AS3 player when used in conjunction with theplaylist
parameter. To loop a single video, set theloop
parameter to1
and set theplaylist
parameter value to the same video ID already specified in the Player API URL:http://www.youtube.com/v/VIDEO_ID?version=3&loop=1&playlist=VIDEO_ID
Similarly, the
controls
andplaylist
parameters are supported in the AS3 and HTML5 players but are not and will not be supported in the AS2 player.As noted above, IFrame embeds can load either an AS3 or HTML5 player. Though some parameters are not supported in both players, an IFrame embed that loads the AS3 player will support all parameters that work with that player and ignore all other parameters. Similarly, an IFrame embed that loads the HTML5 player will support all parameters that work with that player while ignoring all other parameters.
- The parameter list has been updated to include the
autohide
parameter, which indicates whether the player’s video controls will automatically hide after a video begins playing. - The parameter list has been updated to include the
controls
parameter, which indicates whether the player’s video controls will display at all. (Player controls do display by default.) - The parameter list has been updated to include the
playlist
parameter, which specifies a comma-separated list of video IDs to play. - The definition of the
fs
has been updated to note that the fullscreen option will not work if you load the YouTube player into another SWF. - The example at the end of the document has been updated to use the embedded AS3 player instead of the embedded AS2 player. The parameters used in the example have also been updated to only include parameters that the AS3 player supports.
In addition, the instructions for constructing the URLs that contain player parameters have been updated to reflect the URL formats used by the AS3 and AS2 embedded and chromeless players as well as by the HTML5 player.