javascript - Already embedded iframe not working with the youtube api -



javascript - Already embedded iframe not working with the youtube api -

my iframe html

<iframe id="player" frameborder="0" width="660" height="371" allowfullscreen="" src="https://www.youtube.com/embed/cmm6tdavsxg?feature=oembed">

my youtube js

var tag = document.createelement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag); var player; function onyoutubeiframeapiready() { player = new yt.player('player', { events: { 'onready': onplayerready, 'onstatechange': onplayerstatechange } }); } function onplayerready(event) { event.target.playvideo(); }

but still not start playing or else... issue here? give thanks you

onplayerready not fire ready check on localhost. also when linking youtube.js file has come after iframe. add ?enablejsapi=1 sometimes double linking in both player_api , iframe_api help //< before www. not https:// placment key.

edit: problem fact need add together ?enablejsapi=1 video embed link.

//www.youtube.com/embed/f4efzdqxzka?enablejsapi=1

fiddle: http://jsfiddle.net/y89je0k8/

that solve problem.

javascript iframe youtube youtube-api

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -