Skip to content

Commit

Permalink
fix: correct and wrong sounds (BL-13998)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-polk committed Nov 12, 2024
1 parent 405a0bc commit bf34f51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
24 changes: 12 additions & 12 deletions src/activities/ActivityContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import {
getPageData,
storePageData
} from "../page-api";
// import doesn't work here...if we really want it to
// https://stackoverflow.com/questions/56782452/how-to-fix-module-not-found-for-audio-files-using-file-loader-images-css-an
// has some ideas.
import rightAnswer from "./right_answer.mp3";
import wrongAnswer from "./wrong_answer.mp3";

Expand Down Expand Up @@ -72,18 +69,21 @@ export class ActivityContext {
}

public playCorrect() {
// NB: if this stops working in storybook; the file should be found because the package.json
// script that starts storybook has a "--static-dir" option that should include the folder
// containing the standard activity sounds.
// require on an mp3 in storybook gives us some sort of module object where the url of the sound is its 'default'
// whatever we're doing to build the production version, require on the mp3 gives us the url directly.
this.playSound(rightAnswer.default ?? rightAnswer);
let path = rightAnswer;
if (path.startsWith("/")) {
// I can't figure out how to get rid of the leading slash in the path in the production build.
path = path.substring(1);
}
this.playSound(path);
}

public playWrong() {
// require on an mp3 gives us some sort of module object where the url of the sound is its 'default'
// whatever we're doing to build the production version, require on the mp3 gives us the url directly.
this.playSound(wrongAnswer.default ?? wrongAnswer);
let path = wrongAnswer;
if (path.startsWith("/")) {
// I can't figure out how to get rid of the leading slash in the path in the production build.
path = path.substring(1);
}
this.playSound(path);
}

private getPagePlayer(): any {
Expand Down
2 changes: 1 addition & 1 deletion src/stories/controlBarInteractionl.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Meta, StoryFn } from "@storybook/react";
import { within, userEvent } from "@storybook/testing-library";
import { within, userEvent } from "@storybook/test";
import { expect } from "@storybook/test";
import { ControlBar } from "../controlBar";
import LangData from "../langData";
Expand Down
7 changes: 1 addition & 6 deletions src/stories/playerInteraction.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import React from "react";
import { StoryFn, Meta } from "@storybook/react";
import {
within,
userEvent,
waitFor,
fireEvent,
} from "@storybook/testing-library";
import { within, userEvent, waitFor, fireEvent } from "@storybook/test";
import { expect } from "@storybook/test";
import { BloomPlayerControls } from "../bloom-player-controls";

Expand Down

0 comments on commit bf34f51

Please sign in to comment.