How do I stop an iframe video?
Example 2: Loud playback This example creates a 1280px by 720px video player. The event listener for the onReady event then calls the setVolume function to adjust the volume to the highest setting. function onYouTubeIframeAPIReady() { var player; player = new YT.Player('player', { width: 1280, height: 720, videoId: 'M7lc1UVf-VE', events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange, 'onError': onPlayerError } }); } function onPlayerReady(event) { event.target.setVolume(100); event.target.playVideo(); }Example 3: This example sets player parameters to automatically play the video when it loads and to hide the video player's controls. It also adds event listeners for several events that the API broadcasts. function onYouTubeIframeAPIReady() { var player; player = new YT.Player('player', { videoId: 'M7lc1UVf-VE', playerVars: { 'autoplay': 1, 'controls': 0 }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange, 'onError': onPlayerError } }); }Controlling 360° videosThis example uses the following code:
Revision historyApril 27, 2021The Getting Started and Loading a Video Player sections have been updated to include examples of using a playerVars object to customize the player. October 13, 2020Note: This is a deprecation announcement for the embedded player functionality that lets you configure the player to load search results. This announcement affects the IFrame Player API's queueing functions for lists, cuePlaylist and loadPlaylist. This change will become effective on or after 15 November 2020. After that time, calls to the cuePlaylist or loadPlaylist functions that set the listType property to search will generate a 4xx response code, such as 404 (Not Found) or 410 (Gone). This change also affects the list property for those functions as that property no longer supports the ability to specify a search query. 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. October 24, 2019The documentation has been updated to reflect the fact that the API no longer supports functions for setting or retrieving playback quality. As explained in this YouTube Help Center article, to give you the best viewing experience, YouTube adjusts the quality of your video stream based on your viewing conditions. The changes explained below have been in effect for more than one year. This update merely aligns the documentation with current functionality:
May 16, 2018The API now supports features that allow users (or embedders) to control the viewing perspective for 360° videos:
This example demonstrates and lets you test these new features. June 19, 2017This update contains the following changes:
August 11, 2016This update contains the following changes:
June 29, 2016This update contains the following changes:
June 24, 2016The Examples section has been updated to include an example that demonstrates how to use the API with an existing January 6, 2016The clearVideo function has been deprecated and removed from the documentation. The function no longer has any effect in the YouTube player. December 18, 2015European 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. April 28, 2014This update contains the following changes:
March 25, 2014This update contains the following changes:
July 23, 2013This update contains the following changes:
October 31, 2012This update contains the following changes:
August 22, 2012This update contains the following changes:
August 6, 2012This update contains the following changes:
July 19, 2012This update contains the following changes:
July 16, 2012This update contains the following changes:
June 6, 2012This update contains the following changes:
March 30, 2012This update contains the following changes:
March 26, 2012This update contains the following changes:
|