Hey! Great that you’re exploring Lottie interactivity with Canvas rendering — it’s a bit trickier than with the usual Lottie Web Player (SVG/HTML), because the Canvas API is lower-level and the interactivity library (LottieInteractivity) is designed mostly around the Web Player.
What’s going on?
Your code creates the DotLottie player with a canvas element — that works fine.
But your player_2 is just the canvas DOM element, not the Lottie player instance.
The “ready” event is an event from the Lottie player instance, not the canvas element.
Also, player_2.getLottie() doesn’t exist because player_2 is just the canvas element, not a player object.
Thanks for your explanation Hery. I somehow knew this code doesn’t make much sense but thought I would try. I think I will stick with the Lottie player for now.
Just one last question. Is it possible to move the src attribute and the Url from the html and include it programatically. For example:
Html looks like that: <dotlottie-player src="https://assets.codepen.io/9400490/cycling.lottie" background="transparent" speed="1" direction="1" autoplay="" loop="" playMode="normal" style="width:220px; height:220px;"></dotlottie-player>