It looks like you're new here. If you want to get involved, click one of these buttons!
<<widget "video">> <<set $videoid to passage()>> <<script>> var tag = document.createElement('script'); tag.src = "htps://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var videoID = State.variables.videoid; var player; function onYouTubeIframeAPIReady() { player = new YT.Player('gameplayer', { width: '1600', height: '900', playerVars: { 'autoplay': 1, 'controls': 0, 'disablekb': 0, 'enablejsapi': 1, 'iv_load_policy': 3, 'fs': 0, 'modestbranding': 1, 'rel': 0, 'showinfo': 0 }, videoId: videoID }); } <</script>> <</widget>>(The iframe api url is not correct (htps) became the forum displays a weird thing if I leave https.)
Comments
You didn't show the element which the YouTube player should replace. Are you placing it on the page somewhere?
Also, why are you naming passages after YouTube video IDs, rather than simply passing the ID in as an argument to the widget? It seems like the latter would be far more simple.
SUGGESTIONS
I'd suggest putting the API loader within your script section so it is only loaded once at startup, via the following code: (Twine 2: Story JavaScript; Twine 1: script-tagged passage) NOTE: As you've noticed, the forums try to load some URLs, so the one used above is intentionally incorrect. Simply change the htps: to https:.
The above will also wrap the API load within SugarCube's load screen, so the player cannot proceed until it's ready.
For the player widget itself:
Widget: Usage:
I have to say I'm not familiar with Sugarcube tasks yet, but still learning...
Helped me a lot, thanks again