Load the IFrame Player API code asynchronously. This code does not define any player parameters and also does not define other event handlers. The onYouTubePlayerAPIReady() function specified here is called automatically when the IFrame Player API code has loaded. 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. Within that object, the playerVars property identifies player parameters. The second parameter in the constructor for the video player is an object that specifies player options. Since the URL sets the autoplay parameter to 1, the video would play automatically once the player has loaded.Įmbed a player using the IFrame Player APIįollow 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 tag below would load a 640x360px player that would play the YouTube video M7lc1UVf-VE. The URL has the following format: VIDEO_ID If you create the 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 tag's height and width parameters specify the dimensions of the player. Embed a player using an tagĭefine an 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 following section explains how to configure your player to load a playlist or a user's uploaded videos. Note that the instructions below demonstrate how to embed a player that loads a single video. You can use any of the following methods to embed a YouTube player in your application and specify player parameters. We recommend 16:9 players be at least 480 pixels wide and 270 pixels tall. If the player displays controls, it must be large enough to fully display the controls without shrinking the viewport below the minimum size. Note: Embedded players must have a viewport that is at least 200px by 200px. Each parameter definition identifies the players that support the corresponding parameter. This page currently defines all parameters supported in any YouTube embedded player. You can also use the enablejsapi parameter to enable the player to be controlled via the IFrame Player API. For example, you can automatically play videos using the autoplay parameter or cause a video to play repeatedly using the loop parameter. Removing the iFrame macro and adding a link to the website instead.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.īy appending parameters to the IFrame URL, you can customize the playback experience in your application. Replacing with at the start of the URL to access content more securely. If the website you're trying to include isn't showing up in the iFrame, try: The browser you're using has blocked the website from loading as a security precaution. The website administrators have invoked the x-frame-options response header to prevent browsers from rendering it in an iFrame. Some websites may show up as blank when you try to include them as part of an iFrame. Changing the values of these attributes won't affect how content in the iFrame macro appears. The remaining attributes (ID, class, styles, title, long description, margin height, margin width, name, text direction, and language code) are being deprecated. This is especially helpful for content that won't display properly below a certain size.Īlign the iframe to the left or right of the page.ĭraw a border around content in the iframe to help distinguish it from other content on the page.Īllow or prevent scrolling in the iFrame to see additional content. Set a fixed height and width for your iframe.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |