diff --git a/frontend/src/stories/Playback.stories.tsx b/frontend/src/stories/Playback.stories.tsx index 5383b2af5..efccd80be 100644 --- a/frontend/src/stories/Playback.stories.tsx +++ b/frontend/src/stories/Playback.stories.tsx @@ -3,6 +3,8 @@ import Playback, { PlaybackProps } from "../components/Playback/Playback"; import { AUTOPLAY } from "../types/Playback"; import audio from "./assets/music.ogg"; +import useBoundStore from "@/util/stores"; +import { StoryFn } from "@storybook/react"; export default { title: "Playback", @@ -12,55 +14,76 @@ export default { }, }; -export const Button = { - args: { - playbackArgs: { +// Create a decorator that dynamically accepts a play_method +const createCommonDecorator = (play_method: "BUFFER" | "EXTERNAL") => (Story: StoryFn) => { + const [initialized, setInitialized] = useState(false); + + const setRound = useBoundStore((state) => state.setRound); + const setCurrentAction = useBoundStore((state) => state.setCurrentAction); + setRound([{ + view: "TRIAL_VIEW", + playback: { view: AUTOPLAY, - play_method: "BUFFER", + play_method, show_animation: true, preload_message: "Loading audio...", instruction: "Click the button to play the audio.", - sections: [ - { - id: 0, - url: audio, - } - ], + sections: [{ id: 0, url: audio }], play_from: 0.0, resume_play: false, - }, - onPreloadReady: () => { }, - autoAdvance: false, - responseTime: 10, - submitResult: () => { }, - finishedPlaying: () => { }, - } as PlaybackProps, - decorators: [ - (Story) => { + } + }]); + setCurrentAction(0); - const [initialized, setInitialized] = useState(false); + if (!initialized) { + return ( + <> + + > + ); + } + return ( +