avaneeshtripathi / react-dice-roll

A highly customizable dice roll package built in react.
https://www.npmjs.com/package/react-dice-roll
34 stars 23 forks source link

how to add sound on role #3

Closed Adarsh1999 closed 4 years ago

Adarsh1999 commented 4 years ago

Hi I want to add the sound on dice roll and I saw you have given a prop dedicated to sound too. But it is not working here what I have done:

const audio = new Audio("/audio.mp3");

<Dice onRoll={(value) => scoring(value)} size={90} sound={audio} faceBg={"White"} faces={dice_face} disabled={true} />

So plz can you correct me if I am doing wrong method and the length of audio is 2sec.

avaneeshtripathi commented 4 years ago

Hi @Adarsh1999, Please refer the documentation. Sound prop accepts string which is the url for sound file. So rather passing the audio object for the file you can directly pass the url. Keeping this issue open for now. Let me know if this resolves the issue you are facing so we can close it.

Adarsh1999 commented 4 years ago

Yeah @avaneeshtripathi it correctly worked when i did gave the exact path like: sound={"/audio.mp3"}. Thanks for your help..