when create iframe player api using onyoutubeiframeapiready
, link created http
protocol
example:
// 2. code loads 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. function creates <iframe> (and youtube player) // after 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 know how video created https
protocol? need install api on platform.
please, suggest!
you can specify https if create iframe element directly in html, rather using div gets replaced later on. can create iframe tag dynamically if need to. @ bottom of this section, spells out how it.
beware — if load player on https, actual video stream may served on http. seems cause mixed-mode warning in chrome, though not other browsers (in experience last year; may have since changed). see this official blog post, explains player can loaded on https warns video still won't served way.
Comments
Post a Comment