Visão geral
Este documento explica como incorporar um player do YouTube em seu aplicativo e ainda define os parâmetros disponíveis nele.
Ao anexar parâmetros ao URL do iframe, você pode personalizar a experiência de reprodução no seu aplicativo. Por exemplo, é possível reproduzir vídeos automaticamente usando o parâmetro autoplay ou fazer com que um vídeo seja reproduzido repetidamente usando o parâmetro loop. Você também pode usar o parâmetro enablejsapi para permitir que o player seja controlado pela API IFrame Player.
No momento, estão definidos nesta página todos os parâmetros aceitos em qualquer player incorporado do YouTube. Os players compatíveis com um determinado parâmetro são identificados em cada definição de parâmetro.
Observação: os players incorporados precisam ter uma Janela de visualização com pelo menos 200 px X 200 px. Se o player mostra controles, ele tem que ser grande o suficiente para exibir completamente os controles sem encolher a Janela visualização abaixo do tamanho mínimo. Recomendamos que players de 16:9 tenham pelo menos 480 pixels de largura e 270 pixels de altura.
Incorporar um player do YouTube
Você pode usar qualquer método a seguir para incorporar um player do YouTube em seu aplicativo e especificar seus parâmetros. As instruções abaixo demonstram como incorporar um player que carregue um vídeo único. A seção a seguir explica como configurar o player para carregar uma playlist ou os vídeos enviados de um usuário.
Incorporar um player usando uma tag <iframe>
Defina uma tag <iframe> no seu aplicativo em que o URL src especifica o conteúdo que o player vai carregar, além de outros parâmetros que você quer definir. Os parâmetros height e width da tag <iframe> especificam as dimensões do player.
Se você criar o elemento <iframe> por conta própria (em vez de usar a API IFrame Player), adicione os parâmetros do player diretamente ao final do URL. O URL tem o seguinte formato:
https://www.youtube.com/embed/VIDEO_ID
A tag <iframe> abaixo carregaria um player de 640 x 360 px que reproduziria o vídeo do YouTube M7lc1UVf-VE. Como o URL define o parâmetro autoplay como 1, o vídeo é reproduzido automaticamente assim que o player é carregado.
<iframe id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com" frameborder="0"></iframe>
Incorporar um player usando a API IFrame Player
Siga as instruções da IFrame Player API para inserir um player de vídeo em sua página da Web ou em seu aplicativo após o carregamento do código de JavaScript da API do player. O segundo parâmetro no construtor do player de vídeo é um objeto que especifica as opções do player. Nesse objeto, a propriedade playerVars identifica os parâmetros do jogador.
O código HTML e JavaScript abaixo mostra um exemplo simples que insere um player do YouTube no elemento da página com um valor id de ytplayer. A função onYouTubePlayerAPIReady() especificada aqui é chamada automaticamente quando o código da API IFrame Player é carregado. Este código não define parâmetros do player nem outros manipuladores de eventos.
<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: '360',
      width: '640',
      videoId: 'M7lc1UVf-VE'
    });
  }
</script>
Selecionar o conteúdo para tocar
Você pode configurar o player incorporado para carregar um vídeo, uma playlist ou os vídeos enviados de um usuário.
A lista que segue explica essas opções:
- 
    Carregar um vídeo Para uma incorporação de IFrame, o ID do vídeo do YouTube que você quer carregar é especificado no URL srcdo IFrame.https://www.youtube.com/embed/VIDEO_ID Se estiver usando a API de dados (v3) do YouTube, você pode construir esses URLs de forma programática com a recuperação dos IDs do vídeo de resultados de pesquisa, recursos de item de playlist, recursos de vídeo ou outros recursos. Depois de conseguir um ID de vídeo, substitua o texto VIDEO_IDnos URLs acima por esse valor para criar o URL do player.
- 
    Carregar uma playlist Defina o parâmetro do player listTypecomoplaylist. Além disso, defina o parâmetro do playerlistcomo o ID da playlist do YouTube que você quer carregar.https://www.youtube.com/embed?listType=playlist&list=PLAYLIST_ID É necessário adicionar as letras PLno início do ID da playlist, conforme mostrado no exemplo a seguir:https://www.youtube.com/embed?listType=playlist&list=PLC77007E23FF423C6 Se estiver usando a API de dados (v3) do YouTube, você pode construir esses URLs de forma programática com a recuperação dos IDs da playlist de resultados de pesquisa, recursos do canal ou recursos de atividade. Depois de conseguir um ID de playlist, substitua o texto PLAYLIST_IDno URL acima por esse valor.
- 
    Carregar os vídeos enviados por um usuário Defina o parâmetro do player listTypecomouser_uploads. Além disso, defina o parâmetro do playerlistcom o nome de usuário do YouTube cujos vídeos enviados você quer carregar.https://www.youtube.com/embed?listType=user_uploads&list=USERNAME 
Parâmetros aceitos
Todos os parâmetros a seguir são opcionais.
| Parâmetros | |
|---|---|
| 
 | Esse parâmetro especifica se o vídeo inicial vai começar a ser reproduzido automaticamente quando o player for carregado. Os valores aceitos são 0ou1. O valor padrão é0.Se você ativar a reprodução automática, ela vai ocorrer sem interação do usuário com o player. Portanto, a coleta e o compartilhamento de dados de reprodução vão ocorrer no carregamento da página. | 
| 
 | Este parâmetro especifica o idioma padrão que será utilizado pelo player para exibir legendas. Defina o valor do parâmetro como um código de idioma de duas letras ISO 639-1. Se você usar esse parâmetro e também definir o parâmetro cc_load_policycomo1, o player vai mostrar legendas no idioma especificado quando for carregado. Se você não definir o parâmetrocc_load_policy, as legendas não vão aparecer por padrão, mas serão exibidas no idioma especificado se o usuário ativar esse recurso. | 
| 
 | Definir o valor do parâmetro como 1faz com que as legendas descritivas sejam mostradas por padrão, mesmo que o usuário as tenha desativado. O comportamento padrão é baseado na preferência do usuário. | 
| 
 | Este parâmetro especifica a cor que será usada na barra de progresso do vídeo, no player, para destacar a quantidade de vídeos que o usuário já visualizou. Os valores de parâmetro válidos são redewhite. Por padrão, o player usa a cor vermelha na barra de progresso do vídeo. Consulte o blog da API do YouTube para mais informações sobre as opções de cores. | 
| 
 | Esse parâmetro indica se os controles do player de vídeo são exibidos: 
 | 
| 
 | Definir o valor do parâmetro como 1faz com que o player não responda aos controles do teclado. O valor padrão é0, o que significa que os controles do teclado estão ativados. No momento, os controles de teclado compatíveis são:
 | 
| 
 | Definir o valor do parâmetro como 1permite que o player seja controlado por chamadas da API IFrame Player. O valor padrão é0, o que significa que o player não pode ser controlado usando essa API.Para mais informações sobre a API IFrame e como usá-la, consulte a documentação da API IFrame. | 
| 
 | Este parâmetro especifica o tempo, medido em segundos, desde o início do vídeo, quando o player deve parar de reproduzir o vídeo. O valor do parâmetro é um número inteiro positivo. O tempo é medido desde o início do vídeo, e não do valor do parâmetro startdo player ou do parâmetrostartSeconds, que é usado nas funções da API YouTube Player para carregar ou enfileirar um vídeo. | 
| 
 | Definir esse parâmetro como 0impede que o botão de tela cheia apareça no player. O valor padrão é1, que faz com que o botão de tela cheia seja exibido. | 
| 
 | Define o idioma da interface do player. O valor do parâmetro é um código de idioma ISO 639-1 de duas letras ou uma localidade totalmente especificada. Por exemplo, frefr-casão valores válidos. Outros códigos de entrada de idioma, como tags de idioma IETF (BCP 47), também podem ser processados corretamente.O idioma da interface é usado para dicas no player e também afeta a faixa de legenda padrão. É possível que um idioma da faixa de legenda diferente seja selecionado pelo YouTube para um determinado usuário com base nas preferências individuais de idioma do usuário e na disponibilidade das faixas de legenda. | 
| 
 | Definir o valor do parâmetro como 1faz com que as anotações de vídeo sejam mostradas por padrão, enquanto definir como3faz com que elas não sejam mostradas por padrão. O valor padrão é1. | 
| 
 | O parâmetro list, junto com o parâmetrolistType, identifica o conteúdo que será carregado no player.
 listelistType, o URL de incorporação do iframe não precisará especificar um ID de vídeo. | 
| 
 | O parâmetro listType, junto com o parâmetrolist, identifica o conteúdo que será carregado no player. Os valores de parâmetro válidos sãoplaylisteuser_uploads.Se você especificar valores para os parâmetros listelistType, o URL de incorporação do iframe não precisará especificar um ID de vídeo.Observação:um terceiro valor de parâmetro, search, foi descontinuado e não será mais compatível a partir de | 
| 
 | No caso de um único player de vídeo, uma configuração de 1faz com que o player reproduza o vídeo inicial várias vezes. No caso de um player de playlist (ou player personalizado), ele toca a playlist inteira e depois começa de novo no primeiro vídeo.Os valores aceitos são 0e1, e o valor padrão é0.Observação:esse parâmetro tem suporte limitado em incorporações de iframe. Para repetir um único vídeo, defina o valor do parâmetro loopcomo1e o valor do parâmetroplaylistcomo o mesmo ID de vídeo já especificado no URL da API Player:https://www.youtube.com/embed/VIDEO_ID?playlist=VIDEO_ID&loop=1 | 
| 
 | Observação:esse parâmetro foi descontinuado e não tem efeito. Consulte o comunicado sobre a descontinuação para mais informações. | 
| 
 | Este parâmetro fornece uma medida de segurança adicional para o IFrame API, sendo aceito apenas em incorporações do IFrame. Se você estiver usando a API IFrame, ou seja, definindo o valor do parâmetro enablejsapicomo1, sempre especifique seu domínio como o valor do parâmetroorigin. | 
| 
 | Esse parâmetro especifica uma lista separada por vírgulas de IDs de vídeos a serem reproduzidos. Se você especificar um valor, o primeiro vídeo a ser reproduzido será o VIDEO_IDespecificado no caminho do URL, e os vídeos especificados no parâmetroplaylistserão reproduzidos em seguida. | 
| 
 | Esse parâmetro controla se os vídeos são reproduzidos inline ou em tela cheia no iOS. Os valores válidos são: 
 | 
| 
 | Observação:esse parâmetro vai mudar a partir de 25 de setembro de 2018. Antes da mudança, esse parâmetro indicava se o player deveria mostrar vídeos relacionados quando a reprodução do vídeo inicial terminasse. 
 relestiver definido como0, os vídeos relacionados serão do mesmo canal do vídeo que acabou de ser reproduzido. | 
| 
 | Este parâmetro faz com que o player comece a reproduzir o vídeo em um número determinado de segundos a partir do início do vídeo. O valor do parâmetro é um número inteiro positivo. Assim como a função seekTo, o player vai procurar o frame-chave mais próximo do horário especificado. Isso quer dizer que, algumas vezes, o marcador da reprodução pode chegar até um pouco antes do tempo solicitado, não mais do que dois segundos, em geral. | 
| 
 | Esse parâmetro identifica o URL em que o player está incorporado. Esse valor é usado nos relatórios do YouTube Analytics quando o player do YouTube é incorporado a um widget, que é incorporado a uma página da Web ou um aplicativo. Nesse cenário, o parâmetro originidentifica o domínio do provedor de widget, mas o YouTube Analytics não deve identificar o provedor como a origem de tráfego real. Em vez disso, o YouTube Analytics usa o valor do parâmetrowidget_referrerpara identificar o domínio associado à origem de tráfego. | 
Histórico de revisões
August 15, 2023
Note: This is a deprecation announcement for the 
  modestbranding parameter.
The modestbranding parameter is deprecated and will 
  have no effect. To align with YouTube's branding requirements, the player now determines the 
  appropriate branding treatment based on a combination of factors, including player size, other API 
  parameters (e.g. controls), and additional signals.
April 27, 2021
The playsinline parameter definition has been updated
  slightly to explain that the parameter pertains to both mobile browsers on iOS and iOS
  WebViews.
October 15, 2020
The autoplay parameter definition has been updated to
    explain that if you enable Autoplay, playback will occur without any user interaction with the
    player; playback data collection and sharing will therefore occur upon page load.
October 13, 2020
Note: This is a deprecation announcement for the embedded player
  functionality that lets you configure the player to load search results. This announcement affects
  the player's list and
  listType parameters.
This change will become effective on or after listType parameter value to search will generate a
  4xx response code, such as 404 (Not Found) or
    410 (Gone).
As an alternative, you can use the YouTube Data API's
  search.list method to retrieve search
  results and then load selected videos in the player.
In addition to the change described above, the showinfo parameter, which was
  deprecated in 2018, has been removed from this document.
August 23, 2018
Note: This is a deprecation announcement for the showinfo parameter. In addition, the behavior for the rel parameter is changing. Titles, channel information, and related videos are an important part of YouTube's core user experience, and these changes help to make the YouTube viewing experience consistent across different platforms.
- The behavior for the relparameter is changing on or after September 25, 2018. The effect of the change is that you will not be able to disable related videos. However, you will have the option of specifying that the related videos shown in the player should be from the same channel as the video that was just played.
 To be more specific:- Prior to the change, if the parameter's value is set to 0, then the player does not show related videos.
- After the change, if the relparameter is set to0, the player will show related videos that are from the same channel as the video that was just played.
 
- Prior to the change, if the parameter's value is set to 
- The showinfoparameter, which indicates whether the player should display information like the video title and uploader before the video starts playing, is also being deprecated. Following the change, the channel avatar and video title will always display before playback begins, when playback is paused, and when playback ends. The avatar being displayed is new behavior that will be consistent across all embedded players.
These changes will become effective on or after September 25, 2018. After that time, the showinfo parameter will be ignored. The behavior following the changes is consistent with the current default behavior for embedded players with the exception of the channel avatar changes mentioned above.
August 16, 2018
The cc_lang_pref parameter can be used to specify the default language that the player will use to display captions. This parameter can be used in conjunction with the cc_load_policy parameter to automatically show captions in the specified language during playback.
September 15, 2017
The controls parameter's definition has been updated to remove references to the deprecated Flash (AS3) player. The value 2 has been deprecated as it was originally designed to provide a performance improvement for embeds that loaded a Flash player.
June 12, 2017
The new widget_referrer parameter helps to enable more accurate YouTube Analytics reporting when the YouTube player is embedded in a widget, and that widget is then embedded in a web page or application.
November 1, 2016
This document has been updated to remove references to the deprecated Flash (AS3) player as well as to parameters only supported by that player. The YouTube Flash player was deprecated in January 2015.
October 20, 2016
This update contains the following changes:
- 
    The disablekbparameter definition has been corrected to note that the default value is0, which means that keyboard controls are enabled. A value of1indicates that keyboard controls should be disabled.The list of keyboard controls that the player supports has also been updated to include the following: - [f]: Toggle full-screen display
- [j]: Jump back 10 seconds in the current video
- [k]: Play / Pause
- [l]: Jump ahead 10 seconds in the current video
- [m]: Mute or unmute the video
- [0-9]: Jump to a point in the video. 0jumps to the beginning of the video,1jumps to the time 10% into the video,2jumps to the point 20% into the video, and so forth.
 In addition, the effect of pressing the [arrow left] or [arrow right] keys has changed. These keys now jump 5 seconds back (arrow left) or ahead (arrow right) in the current video. 
August 11, 2016
This update contains the following changes:
- 
    The newly published YouTube API Services Terms of Service ("the Updated Terms"), discussed in detail on the YouTube Engineering and Developers Blog, provides a rich set of updates to the current Terms of Service. In addition to the Updated Terms, which will go into effect as of February 10, 2017, this update includes several supporting documents to help explain the policies that developers must follow. The full set of new documents is described in the revision history for the Updated Terms. In addition, future changes to the Updated Terms or to those supporting documents will also be explained in that revision history. You can subscribe to an RSS feed listing changes in that revision history from a link in that document. 
December 18, 2015
European Union (EU) laws require that certain disclosures must be given to and consents obtained from end users in the EU. Therefore, for end users in the European Union, you must comply with the EU User Consent Policy. We have added a notice of this requirement in our YouTube API Terms of Service.
August 19, 2015
- 
    The autohideparameter 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 anautohidesetting of1.
- 
    The themeparameter 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 autohideparameter 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 hlparameter 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,frandfr-caare both valid parameter values.
- 
    The definition of the enablejsapiparameter 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, andlistTypeparameters. The parameter descriptions have been updated accordingly.
July 18, 2014
- 
    The new hlparameter 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 playsinlineparameter, which only affects HTML5 players on iOS, has been modified slightly. The definition now notes that setting the parameter value to1causes inline playback only forUIWebViewscreated with theallowsInlineMediaPlaybackproperty set toTRUE.
January 28, 2014
- 
    The playsinlineparameter controls whether videos play inline or fullscreen in an HTML5 player on iOS. Setting the value to1causes 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 controlsparameter'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 controlsparameter has been updated to reflect support for a parameter value of2and to explain that, for AS3 players, the parameter value determines the time when the Flash player actually loads. If thecontrolsparameter is set to0or1, 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, andrelparameters, and the definitions for these parameters have been updated accordingly.
- 
    The definition of the showinfoparameter 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 showinfoparameter'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 endparameter 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 thestartplayer parameter or thestartSecondsparameter, 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 listandlistTypeparameters 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 fsandrelparameters have been updated to more clearly explain the default parameter values for the AS3 player.
- 
    The border,color1,egm,hd, andshowsearchparameters, 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 themeandcolorparameters 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 modestbrandingparameter 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 loopparameter has limited support in the AS3 player and in IFrame embeds, which could load either an AS3 or HTML player. Currently, theloopparameter only works in the AS3 player when used in conjunction with theplaylistparameter. To loop a single video, set theloopparameter to1and set theplaylistparameter value to the same video ID already specified in the Player API URL:https://www.youtube.com/v/VIDEO_ID?version=3&loop=1&playlist=VIDEO_ID Similarly, the controlsandplaylistparameters 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 autohideparameter, 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 controlsparameter, 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 playlistparameter, which specifies a comma-separated list of video IDs to play.
- 
    The definition of the fshas 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.