As part of my efforts to track when a user pauses a YouTube video (link to the question), I have been utilizing the onYouTubeIframeAPIReady callback method in Angular2.
I am facing similar challenges as discussed here and here.
Following the recommendations, I resorted to using
(window as any).onYouTubeIframeAPIReady = function () {}
.
Within my onYouTubeIframeAPIReady function, the code looks like this:
function onYouTubeIframeAPIReady() {
player = new YT.Player('video', {
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
However, I encounter the following error from my TypeScript linter:
Argument of type '{events: {'onReady':(event:any) => void; 'onStateChange': (event:any)=>void;};}' is not assignable to parameter of type 'PlayerOptions'
You can find my minimal example repository here:
git clone https://github.com/Atticus29/dataJitsu.git
cd dataJitsu
git checkout stackoverflow
npm install
ng serve