Youtube https API protocol

When I create an iframe API using onYouTubeIframeAPIReady , the link is created using the http protocol

Example:

  // 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); // 3. This function creates an <iframe> (and YouTube player) // after the API code downloads. var player; function onYouTubeIframeAPIReady() { player = new YT.Player('player', { width: '560', height: '600', videoId: '7j8B_r4OfAw', events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); } 

iframe Result:

 <iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="560" height="600" src="http://www.youtube.com/embed/7j8B_r4OfAw?enablejsapi=1"></iframe> 

Does anyone know how to make a video that will be created using the https protocol? You need to install api on the platform.

Please suggest!

+2
source share
1 answer

You can specify https if you create an iframe directly in your html, instead of using a div, which will be replaced later. You can create an iframe tag dynamically if you need to. Look at the bottom of this section for how to do this.

Beware - even if you download the player on top of https, the actual video stream can be transmitted via http. This is similar to the mixed mode warning in Chrome, but not in other browsers (in my experience last year, it may have changed since then). See this official blog post explaining that the player can be downloaded via https, but warns that the video will still not necessarily be served in this way.

0
source

Source: https://habr.com/ru/post/1210965/


All Articles