w sounds
This commit is contained in:
parent
2621a0e615
commit
55f4eaa1bb
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/pashto-inflector",
|
"name": "@lingdocs/pashto-inflector",
|
||||||
"version": "1.9.3",
|
"version": "1.9.4",
|
||||||
"author": "lingdocs.com",
|
"author": "lingdocs.com",
|
||||||
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
|
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
|
||||||
"homepage": "https://verbs.lingdocs.com",
|
"homepage": "https://verbs.lingdocs.com",
|
||||||
|
|
|
@ -18,6 +18,7 @@ import InlinePs from "../InlinePs";
|
||||||
import { psStringEquals } from "../../lib/p-text-helpers";
|
import { psStringEquals } from "../../lib/p-text-helpers";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { randFromArray } from "../../lib/misc-helpers";
|
import { randFromArray } from "../../lib/misc-helpers";
|
||||||
|
import playAudio from "../../lib/play-audio";
|
||||||
// import { useReward } from 'react-rewards';
|
// import { useReward } from 'react-rewards';
|
||||||
|
|
||||||
const kingEmoji = "👑";
|
const kingEmoji = "👑";
|
||||||
|
@ -144,6 +145,8 @@ export function VPExplorer(props: {
|
||||||
function checkQuizAnswer(a: T.PsString) {
|
function checkQuizAnswer(a: T.PsString) {
|
||||||
if (!quizState) return;
|
if (!quizState) return;
|
||||||
if (isInAnswer(a, quizState.answer)) {
|
if (isInAnswer(a, quizState.answer)) {
|
||||||
|
const toPlay = randFromArray([true, false, false]);
|
||||||
|
if (toPlay) playAudio(`correct-${randFromArray([1,2,3])}`);
|
||||||
setShowCheck(true);
|
setShowCheck(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
handleResetQuiz();
|
handleResetQuiz();
|
||||||
|
@ -156,6 +159,7 @@ export function VPExplorer(props: {
|
||||||
setCurrentCorrectEmoji(randFromArray(correctEmoji));
|
setCurrentCorrectEmoji(randFromArray(correctEmoji));
|
||||||
}, checkDuration * 2);
|
}, checkDuration * 2);
|
||||||
} else {
|
} else {
|
||||||
|
playAudio(`wrong-${randFromArray([1,2])}`);
|
||||||
navigator.vibrate(250);
|
navigator.vibrate(250);
|
||||||
setQuizState({
|
setQuizState({
|
||||||
...quizState,
|
...quizState,
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
export default function playAudio(a: string) {
|
||||||
|
if (!a) return;
|
||||||
|
let audio = new Audio(`https://verbs.lingdocs.com/sounds/${a}.mp3`);
|
||||||
|
audio.addEventListener("ended", () => {
|
||||||
|
audio.remove();
|
||||||
|
audio.srcObject = null;
|
||||||
|
});
|
||||||
|
audio.play().catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue