I'm trying to change the id of a video in my html, which is in another javascript file, where the youtube API is created. I also read the ids of a JSON file.
HTML
<div class="video-container">
<div id="player">
<script>
function routes(arr) {
var out = "";
var a = 3;
for(i = 2; i<a; i++) {
out = arr[i].videoID;
player.loadVideoById("out");
}
</script>
</div>
</div>
Javascript
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', {
playerVars: { 'autoplay': 0, 'controls': 2 },
height: '390',
width: '640',
//videoId: 'xck9LoSvDvc',
events: {
'onReady': onPlayerReady,
}
});
}
But I get the following error:
Uncaught SyntaxError: Unexpected end of input
on the line;
player.loadVideoById("out");
could you help me please!
thank you very much!