# YouTube Player Demo

This page demonstrates the YouTube Player API's functions.
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.

|---|
|   |

<button id="player-demo-redraw-player" type="button" class="button-blue button"> Update player with selected options </button> <button id="toggle-parameters" type="button" class="button">Show player parameters</button> <button id="toggle-controls" type="button" class="button">Show player controls</button> IFrame Embed Code   

**Note:** The embed code above reflects content settings that you entered for the `list` or `playlist` parameters in the player parameters form. You need to remove these values if you want the embed code to use the content specified in the **Player controls** form.

|---|---|
| Content [![](http://developers.google.com/static/youtube/images/icon-help.gif) You can choose to load or cue content in the player. If you select an option to **load** content and then update the player, the player will play the specified content instead of whichever video, if any, is already playing. If you select an option to **cue** content and the update the player, the player loads the video but does not play it. To play the video, you need to click the **Play** link in the player controls section or on the video player itself. Depending on your selection, this page calls one of the following API functions: - loadVideoById - loadVideoByUrl - loadPlaylist - cueVideoById - cueVideoByUrl - cuePlaylist](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | Load video with video ID: Load list of videos with video IDs: Load playlist with playlist ID: Load uploaded videos for channel: Cue video with video ID: Cue list of videos with video IDs: Cue playlist with playlist ID: Cue uploaded videos for channel: Start time (in seconds from start of video): |
| Controls [![](http://developers.google.com/static/youtube/images/icon-help.gif) The controls in this section let you play, pause or stop a video. To seek to a specific point in the video, enter a number in the **Seek to** field, which specifies the time offset, in seconds, from the beginning of the video when playback should begin.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | [Play](about:invalid#zGoSafez)\|[Pause](about:invalid#zGoSafez)\|[Stop](about:invalid#zGoSafez) Seek to: <button class="button-blue button">Go</button> [Previous](about:invalid#zGoSafez)\|[Next](about:invalid#zGoSafez) Go to (playlist index number): <button class="button-blue button">Go</button> Loop videos: off\|[on](about:invalid#zGoSafez) Shuffle videos: [shuffle](about:invalid#zGoSafez)\|[return to original order](about:invalid#zGoSafez) |
| Volume [![](http://developers.google.com/static/youtube/images/icon-help.gif) The mute and unmute controls turn volume off or on. The **Volume on/off** field in the **Statistics** section indicates whether the player is muted. You can adjust the volume of the player by entering a number between 0 and 100 in the **Set volume** field. Tab or click out of the input box to update the volume.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | [Mute](about:invalid#zGoSafez)\|[Unmute](about:invalid#zGoSafez)\|Set: (0-100) \[current level: --\] |
| Rate [![](http://developers.google.com/static/youtube/images/icon-help.gif) The playback rate identifies the speed at which the video is playing. The `getAvailablePlaybackRates()` function returns the set of playback rates in which the current video is available. In this demo, the available playback rates are shown in the **Statistics** section. A value of `1` indicates that the video is playing at normal speed.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | <button class="button-blue button">Update playback rate</button> |
| Size [![](http://developers.google.com/static/youtube/images/icon-help.gif) This section lets you modify the size of the player, using the **setSize(width, height)** function. Typically, this function would only be useful in an ActionScript application. In a JavaScript application, the resized player is still inserted in the object that contains the video player, even if that object is smaller or larger than the resized player.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | Aspect ratio: 16x9 4x3 Dimensions: x 405 <button class="button-blue button">Update player size</button> |
| History [![](http://developers.google.com/static/youtube/images/icon-help.gif) This page calls the **getVideoUrl()** and **getEmbedCode()** functions when the player is ready to play a video. These functions are called again if you load or cue a video. If you call **getVideoUrl()** after a video has played for at least 10 seconds, the URL includes a parameter that specifies the time offset at which the player should begin playing the video.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | [(clear)](about:invalid#zGoSafez) Errors None yet. Events and function calls None yet. |

<br />

Player parameters   
• checked box = parameter value of `1`   
• unchecked box = parameter value of `0`   
• Use the **Iframe Embed Code** to embed a player with the selected options.   

|---|---|
| Parameter | Value |
| autoplay [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- Automatically start playing video when the player loads. **0** (default) -- Do not automatically play video when the player loads.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| cc_load_policy [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- Cause closed captions to be shown by default even if the user has turned captions off. The default behavior is based on the user's preference.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| color [![](http://developers.google.com/static/youtube/images/icon-help.gif) This parameter specifies the color used in the player's video progress bar to show the amount of the video that the viewer has already seen. The default value is **red**.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | red white |
| controls [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- (default) Display player controls in the video player. **0** -- Do not display player controls in the video player.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| disablekb [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- Disable player keyboard controls. **0** (default) -- Enable player keyboard controls. Keyboard controls are: - Spacebar: Play/Pause - Left arrow: Jump back a few seconds in current video. - Right arrow: Jump ahead a few seconds in current video. - Up arrow: Volume up - Down arrow: Volume down](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| enablejsapi [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- Enable the player to be controlled using the IFrame Player API. **0** (default) -- Do not enable the API.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| end [![](http://developers.google.com/static/youtube/images/icon-help.gif) The time offset at which the video should stop playing. The value is a positive integer that specifies the number of seconds into the video that the player stops playback.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| fs [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** (default) -- The player displays a button to view a fullscreen player. **0** -- The player does not display the button.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| hl [![](http://developers.google.com/static/youtube/images/icon-help.gif) Sets the player's interface language. The parameter value is an ISO 639-1 two-letter language code or a fully specified locale, such as `fr` or `fr-ca`. Other language input codes, such as IETF language tags (BCP 47) might also be handled properly. The interface language is used for tooltips in the player and also affects the default caption track.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| iv_load_policy [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** (default) -- Show video annotations. **3** -- Do not show video annotations.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | 1 3 |
| list [![](http://developers.google.com/static/youtube/images/icon-help.gif) In conjunction with the `list` parameter, this parameter identifies the content that loads in the player. - **playlist** -- The `list` parameter specifies a YouTube playlist ID. Make sure the parameter value begins with the letters `PL`. - **user_uploads** -- The `list` parameter specifies the YouTube channel whose uploaded videos are loaded.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| listType [![](http://developers.google.com/static/youtube/images/icon-help.gif) In conjunction with the `list` parameter, this parameter identifies the content that loads in the player. - **user_uploads** -- The `list` parameter specifies the YouTube channel whose uploaded videos are loaded. - **playlist** -- The `list` parameter specifies a YouTube playlist ID. Make sure the parameter value begins with the letters `PL`.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) | user_uploads playlist |
| loop [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- If the player is loading a single video, play the video again and again. If the player is loading a playlist, play the entire playlist and then start again at the first video. **0** (default) -- Do not continuously play video or entire playlist.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| modestbranding [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- Prevent the YouTube logo from displaying in the control bar. A YouTube text label or watermark still displays when the user's mouse pointer hovers over the player. **0** -- A YouTube logo displays in the player control bar.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| playlist [![](http://developers.google.com/static/youtube/images/icon-help.gif) A comma-separated list of video IDs that play in succession.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| playsinline [![](http://developers.google.com/static/youtube/images/icon-help.gif) **1** -- Cause inline playback for `UIWebViews` created with the `allowsInlineMediaPlayback` property set to `TRUE`. **0** (default) -- Cause fullscreen playback. Note that the default value is subject to change.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |
| start [![](http://developers.google.com/static/youtube/images/icon-help.gif) The time offset at which the video should begin playing. The value is a positive integer that specifies the number of seconds into the video that the player should begin. The player looks for the closest keyframe at or before the time that you specify.](https://developers.google.com/youtube/youtube_player_demo.md.txt#) |   |

Statistics [![](http://developers.google.com/static/youtube/images/icon-help.gif) The information in this section describes the status of the video player and the video being played (or the last video to play). The following list shows the API function associated with each field in this section:
- Duration: getDuration()
- Current time: getCurrentTime()
- Player state: getPlayerState()
- Percentage of video loaded: getVideoLoadedFraction()
- Start bytes: getVideoStartBytes()
- Volume (on/off): isMuted()
- Number of videos in playlist: count(getPlaylist())
- Position of current video: getPlaylistIndex()
- Videos in playlist: getPlaylist()
- Bytes loaded: getVideoBytesLoaded() (deprecated)
- Total bytes: getVideoBytesTotal() (deprecated)](https://developers.google.com/youtube/youtube_player_demo#)   
Duration: --:--   
Current time: --:--   
Player state: --   
Start bytes: --   
% of video loaded: --   
Volume (on/off):   
Playback rate: --   
Available rates:   
Deprecated   
Bytes loaded: --   
Total bytes: --   

Number of videos in playlist:   
Position of current video:   
Videos in playlist: