Skip to content

Commit

Permalink
vuexを経由するように
Browse files Browse the repository at this point in the history
  • Loading branch information
X-20A committed Nov 25, 2024
1 parent ded8c10 commit e6a8f62
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import SingEditor from "@/components/Sing/SingEditor.vue";
import { EngineId } from "@/type/preload";
import ErrorBoundary from "@/components/ErrorBoundary.vue";
import { useStore } from "@/store";
import { applyDeviceId } from "@/store/singing";
import { useHotkeyManager } from "@/plugins/hotkeyPlugin";
import AllDialog from "@/components/Dialog/AllDialog.vue";
import MenuBar from "@/components/Menu/MenuBar/MenuBar.vue";
Expand Down Expand Up @@ -100,9 +99,11 @@ watchEffect(() => {
// 再生デバイスの初期化と変更の監視
watchEffect(() => {
applyDeviceId(store.state.savingSetting.audioOutputDevice).catch((e) => {
console.error(e);
});
store.actions
.APPLY_DEVICE_ID({ device: store.state.savingSetting.audioOutputDevice })
.catch((e) => {
console.error(e);

Check warning on line 105 in src/components/App.vue

View workflow job for this annotation

GitHub Actions / build-test

Unexpected console statement
});
});
// ソフトウェアを初期化
Expand Down
8 changes: 7 additions & 1 deletion src/store/singing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ const getSelectedTrackWithFallback = (partialState: {
};

// AudioContextに再生デバイスのIDを設定
export const applyDeviceId = async (device: string) => {
const applyDeviceId = async (device: string) => {
if (audioContext) {
const sinkId = device === "default" ? "" : device;
audioContext.setSinkId(sinkId).catch((err: unknown) => {
Expand Down Expand Up @@ -1698,6 +1698,12 @@ export const singingStore = createPartialStore<SingingStoreTypes>({
},
},

APPLY_DEVICE_ID: {
async action(_, { device }) {
await applyDeviceId(device);
},
},

/**
* レンダリングを行う。レンダリング中だった場合は停止して再レンダリングする。
*/
Expand Down
4 changes: 4 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,10 @@ export type SingingStoreTypes = {
SYNC_TRACKS_AND_TRACK_CHANNEL_STRIPS: {
action(): void;
};

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

export type SingingCommandStoreState = {
Expand Down

0 comments on commit e6a8f62

Please sign in to comment.