youtubeplayer non-angular

1
Hello, I'm trying to implement a youtube player using angular 4, but I'm only able to create it using javascript code. Here is the code:

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;
      setTimeout( 
        function onYouTubeIframeAPIReady() {
          player = new YT.Player('player', {
            height: '360',
            width: '640',
            videoId: 'M7lc1UVf-VE',
          events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
          }
        });
      },3000);

and in the component.ts of the page that I want the player to execute I import the code:

import '../../apiyoutube.js';

The problem is that I want to use several events that I want to recover from the database and etc, so I wanted to manipulate the attributes of this code in services and in the component that use typescript. How do I access attributes of this code in isolation? I already tried to give up but ... how can I create this player using typescript?

    
asked by anonymous 10.11.2017 / 19:23

0 answers