aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-21 02:46:37 +0900
committernsfisis <nsfisis@gmail.com>2024-08-21 02:46:37 +0900
commit483e297f4789fb1fdaa241f87686a00ef55a046d (patch)
treef4227c503ce82ffeba84603f872f7237fbee8ea7 /frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx
parent0765f61a494de1f284042ba56382983d58d5a6f5 (diff)
parent5dba0da3efae63cab5313582a17f20dbb41c6450 (diff)
downloadiosdc-japan-2024-albatross-483e297f4789fb1fdaa241f87686a00ef55a046d.tar.gz
iosdc-japan-2024-albatross-483e297f4789fb1fdaa241f87686a00ef55a046d.tar.zst
iosdc-japan-2024-albatross-483e297f4789fb1fdaa241f87686a00ef55a046d.zip
Merge branch 'feat/audio'
Diffstat (limited to 'frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx')
-rw-r--r--frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx36
1 files changed, 36 insertions, 0 deletions
diff --git a/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx b/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx
new file mode 100644
index 0000000..e299f4b
--- /dev/null
+++ b/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx
@@ -0,0 +1,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>
+ );
+ }
+}