Skip to content

How do I use the SolidJS player? #371

Answered by stanlrt
stanlrt asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone having the same issue, basically do not follow the docs:

import { DotLottie, DotLottieSolid } from "@lottiefiles/dotlottie-solid";
import { createEffect, createSignal } from "solid-js";

import VUIAnim from "./VUI-anim.json";

/**
 * The visual component that indicates volume and speaker changes.
 */
export function VoiceIndicator(props: { volumeLevel: number }) {
	const [lottieRef, setLottieRef] = createSignal<DotLottie>();

	createEffect(() => {
		const lottie = lottieRef();
		if (lottie) {
			lottie.setFrame(Math.round(props.volumeLevel * lottie.totalFrames));
		}
	});

	return (
	        <DotLottieSolid
		        data={VUIAnim}
		        dotLottieRefCallback={setLottieRef}

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@theashraf
Comment options

@stanlrt
Comment options

@stanlrt
Comment options

@moonlitgrace
Comment options

@stanlrt
Comment options

Answer selected by stanlrt
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants