javascript - Youtube Iframe API - Videos not loading -
edit: here jsfiddle : http://jsfiddle.net/sr4u1b0a
i trying figure out how use youtube api. newbie @ this, i'm sorry if there simple solution.
i believe added necessary code make work, won't load video.
https://codepen.io/brianpensinger/pen/zdxzjj
head:
<script src="https://youtube.com/iframe_api" type="text/javascript"></script> <script type="text/javascript"> var player2; function onyoutubeiframeapiready() { player2 = new yt.player("video-placeholder2", { width: 1920, height: 1080, videoid: "im_kmyuli_s", playervars: { modestbranding: 1, rel: 0 }, events: { onready: initialize } }); } function initialize() { setplaybackquality(highres); loadvideobyid(im_kmyuli_s, parseint(0), highres); setplaybackrate(2); } </script> <script type="text/javascript"> var player; function onyoutubeiframeapiready() { player = new yt.player("video-placeholder", { width: 1920, height: 1080, videoid: "im_kmyuli_s", playervars: { modestbranding: 1, rel: 0 }, events: { onready: initialize } }); } function initialize() { setplaybackquality(highres); loadvideobyid(im_kmyuli_s, parseint(0), highres); setplaybackrate(2); } </script>
update, changed loading via script , worked!
var tag = document.createelement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag);
Comments
Post a Comment