voice-changer/client/demo_v13/src/001_globalHooks/001_useVCClient.ts

26 lines
598 B
TypeScript
Raw Normal View History

2023-02-16 18:09:56 +03:00
import { ClientState, useClient } from "@dannadori/voice-changer-client-js"
2023-03-09 00:47:11 +03:00
import { AUDIO_ELEMENT_FOR_PLAY_RESULT, CLIENT_TYPE } from "../const"
2023-02-16 18:09:56 +03:00
export type UseVCClientProps = {
2023-02-16 20:11:03 +03:00
audioContext: AudioContext | null
2023-02-16 18:09:56 +03:00
}
export type VCClientState = {
clientState: ClientState
}
export const useVCClient = (props: UseVCClientProps) => {
const clientState = useClient({
2023-03-09 00:47:11 +03:00
clientType: CLIENT_TYPE,
2023-02-16 18:09:56 +03:00
audioContext: props.audioContext,
audioOutputElementId: AUDIO_ELEMENT_FOR_PLAY_RESULT
})
const ret: VCClientState = {
clientState
}
return ret
}