blob: e299f4b4e39067e74044c276b6884d79a58806f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { useState } from "react";
import { AudioController } from "../.client/audio/AudioController";
import GolfWatchApp, { type Props } from "./GolfWatchApp.client";
export default function GolfWatchAppWithAudioPlayRequest({
game,
sockToken,
}: Omit<Props, "audioController">) {
const [audioController, setAudioController] =
useState<AudioController | null>(null);
const audioPlayPermitted = audioController !== null;
if (audioPlayPermitted) {
return (
<GolfWatchApp
game={game}
sockToken={sockToken}
audioController={audioController}
/>
);
} else {
return (
<div>
<button
onClick={async () => {
const audioController = new AudioController();
await audioController.loadAll();
setAudioController(audioController);
}}
>
Enable Audio Play
</button>
</div>
);
}
}
|