Skip to content

Commit

Permalink
調整
Browse files Browse the repository at this point in the history
  • Loading branch information
X-20A committed Nov 25, 2024
1 parent e6a8f62 commit 78efdb5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
8 changes: 3 additions & 5 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ watchEffect(() => {
// 再生デバイスの初期化と変更の監視
watchEffect(() => {
store.actions
.APPLY_DEVICE_ID({ device: store.state.savingSetting.audioOutputDevice })
.catch((e) => {
console.error(e);
});
void store.actions.APPLY_DEVICE_ID_TO_AUDIO_CONTEXT({
device: store.state.savingSetting.audioOutputDevice,
});
});
// ソフトウェアを初期化
Expand Down
31 changes: 13 additions & 18 deletions src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,21 +754,6 @@ const getSelectedTrackWithFallback = (partialState: {
return getOrThrow(partialState.tracks, partialState._selectedTrackId);
};

// AudioContextに再生デバイスのIDを設定
const applyDeviceId = async (device: string) => {
if (audioContext) {
const sinkId = device === "default" ? "" : device;
audioContext.setSinkId(sinkId).catch((err: unknown) => {
void showAlertDialog({
type: "error",
title: "エラー",
message: "再生デバイスが見つかりません",
});
throw err;
});
}
};

export const singingStoreState: SingingStoreState = {
tpqn: DEFAULT_TPQN,
tempos: [createDefaultTempo(0)],
Expand Down Expand Up @@ -1698,9 +1683,19 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
},
},

APPLY_DEVICE_ID: {
async action(_, { device }) {
await applyDeviceId(device);
APPLY_DEVICE_ID_TO_AUDIO_CONTEXT: {
action(_, { device }) {
if (audioContext) {
const sinkId = device === "default" ? "" : device;
audioContext.setSinkId(sinkId).catch((err: unknown) => {
void showAlertDialog({
type: "error",
title: "エラー",
message: "再生デバイスが見つかりません",
});
throw err;
});
}
},
},

Expand Down
2 changes: 1 addition & 1 deletion src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ export type SingingStoreTypes = {
action(): void;
};

APPLY_DEVICE_ID: {
APPLY_DEVICE_ID_TO_AUDIO_CONTEXT: {
action(payload: { device: string }): void;
};
};
Expand Down

0 comments on commit 78efdb5

Please sign in to comment.