youtube-iframe-api

How to find out when a youtube embedded iframe is loaded

假如想象 提交于 2020-08-08 06:00:08
问题 I am trying to embed a youtube iframe into my application and listen to when that youtube video is loaded and ready to be played; my idea is to have a user press a play button, and not be shown the autoplaying embedded video until the video is completely ready to be played, and thus the user doesn't have to press a button and then wait for the embedded player to load. I tried taking a look at this youtube iframe api documentation and various related stack overflows but still find myself stuck

Accessing elements from player.getIframe() object?

隐身守侯 提交于 2020-08-06 06:42:07
问题 As per https://developers.google.com/youtube/iframe_api_reference player.getIframe():Object This method returns the DOM node for the embedded <iframe>. How can I access the elements of the DOM node like I can do with the parent page's DOM, such as document.getElementById("example") ? 回答1: Here are the children under that player.getIframe():Object <iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="640" height="390" src="https://www.youtube.com/embed

Lazy Load youtube video from iframe API

一曲冷凌霜 提交于 2020-07-05 10:07:15
问题 I want to lazy load the youtube video with iframe API. ie. load only the poster image in the beginning and when user clicks on it then only load the actual image and its content. 回答1: Most of this is taken from the getting started section on the youtube page. <!-- 1. The <iframe> (and video player) will replace this <div> tag. --> <div id="player"></div> <script> // 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script'); tag.src = "https://www

How to remove pause menu video suggestions / related videos (class: ytp-pause-overlay) from Youtube embed

丶灬走出姿态 提交于 2020-06-27 07:17:32
问题 Youtube is showing a menu with video suggestions while my embedded video is paused. The element in the iframe has the class 'ytp-pause-overlay' How can you remove it without removing controls? 回答1: Yes it is possible. You have to use showinfo=0?ecver=2 in your iframe code. Example: <iframe src="https://www.youtube.com/embed/pV1jC37ELmQ?rel=0&showinfo=0?ecver=2" width="640" height="360"></iframe> 回答2: In case you loading your videos using Javascript YouTube Player iframe API you will need to

How to remove pause menu video suggestions / related videos (class: ytp-pause-overlay) from Youtube embed

我只是一个虾纸丫 提交于 2020-06-27 07:17:11
问题 Youtube is showing a menu with video suggestions while my embedded video is paused. The element in the iframe has the class 'ytp-pause-overlay' How can you remove it without removing controls? 回答1: Yes it is possible. You have to use showinfo=0?ecver=2 in your iframe code. Example: <iframe src="https://www.youtube.com/embed/pV1jC37ELmQ?rel=0&showinfo=0?ecver=2" width="640" height="360"></iframe> 回答2: In case you loading your videos using Javascript YouTube Player iframe API you will need to

YouTube iFrame Player API failed to execute postMessage on DOMWindow

徘徊边缘 提交于 2020-04-30 07:24:28
问题 I am trying to load youtube into my web page using YouTube iFrame Player API , and getting following error while loading: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://developer-sandbox.com'). both origin and target are https , there are few SO post which resolves the issue by keeping origin & target url to https. In this case both are same. Following is the JS code I am used to

Youtube disable related videos

混江龙づ霸主 提交于 2020-04-15 09:43:09
问题 I'm using Youtube iframe API to add a video to my page, but it's showing related videos when the video is about to end even though i have set the 'rel' parameter to 0. Here is the concerned part of my code: function onYouTubeIframeAPIReady() { player = new YT.Player('homeplayer', { height: '1070', width: '1920', videoId: videoID, playerVars: { 'controls': 0, 'loop': 1, 'modestbranding': 1, 'rel': 0, 'showinfo': 0, 'playlist': videoID }, events: { 'onReady': onPlayerReady } }); } Maybe this

youtube embed is not working on iphone ios <= 12

青春壹個敷衍的年華 提交于 2020-03-18 09:06:57
问题 On iphone with ios <= 12 when you tap on the video embed the thumbnail flickers and nothing happens. If you click again nothing will happen. The video is not loaded. You can try this even in the official youtube docs: https://developers.google.com/youtube/youtube_player_demo The expected result is the video to load, there is no error shown. Do you have any suggestions on how to fix this ? 回答1: This is not a solution, but we are having the same issue. For now, we are telling our users to

youtube embed is not working on iphone ios <= 12

大城市里の小女人 提交于 2020-03-18 09:05:51
问题 On iphone with ios <= 12 when you tap on the video embed the thumbnail flickers and nothing happens. If you click again nothing will happen. The video is not loaded. You can try this even in the official youtube docs: https://developers.google.com/youtube/youtube_player_demo The expected result is the video to load, there is no error shown. Do you have any suggestions on how to fix this ? 回答1: This is not a solution, but we are having the same issue. For now, we are telling our users to

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('<URL>') does not match the recipient window's origin ('<URL>')

不问归期 提交于 2020-02-07 03:57:44
问题 I'm getting this error: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('<URL>') does not match the recipient window's origin ('<URL>'). My page operates as I'd hoped (I don't notice any unwanted behavior), but I never like ignoring errors in my console, especially if I don't even understand the root cause. My question is NOT A DUPLICATE because I've already studied all of these questions but none of the answers worked: Failed to execute 'postMessage' on 'DOMWindow