You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I think I've found a bug in the Typescript typing. The callback functions such as onReady take a YouTubeEvent argument, that contains a YouTubePlayer object:
function onReady(event: YouTubeEvent) {
const player = event.target;
const time = player.getCurrentTime();
console.log('time:', time);
}
According to the types, time should be a Promise<number>, so you should have to await it. But actually, it is just a plain number. To get my code to typecheck and run I have to actually do:
const time = player.getCurrentTime() as any as number
I'm not really sure what the correct behavior would be. youtube-player wraps the player object and makes every method return promises, which is useful because it allows you to await the method calls until they are ready. But changing event.target to return the wrapped player (and match the types) would probably break some existing code.
I'm using react-youtube version 10.1.0 and youtube-player 5.5.2.
The text was updated successfully, but these errors were encountered:
Hi, I think I've found a bug in the Typescript typing. The callback functions such as
onReady
take aYouTubeEvent
argument, that contains aYouTubePlayer
object:According to the types,
time
should be aPromise<number>
, so you should have to await it. But actually, it is just a plain number. To get my code to typecheck and run I have to actually do:const time = player.getCurrentTime() as any as number
I'm not really sure what the correct behavior would be.
youtube-player
wraps the player object and makes every method return promises, which is useful because it allows you to await the method calls until they are ready. But changing event.target to return the wrapped player (and match the types) would probably break some existing code.I'm using react-youtube version 10.1.0 and youtube-player 5.5.2.
The text was updated successfully, but these errors were encountered: