export type GeneralCommandType = 'MoveUp' | 'MoveDown' | 'MoveLeft' | 'MoveRight' | 'PageUp' | 'PageDown' | 'PreviousLetter' | 'NextLetter' | 'ToggleOsd' | 'ToggleContextMenu' | 'Select' | 'Back' | 'TakeScreenshot' | 'SendKey' | 'SendString' | 'GoHome' | 'GoToSettings' | 'VolumeUp' | 'VolumeDown' | 'Mute' | 'Unmute' | 'ToggleMute' | 'SetVolume' | 'SetAudioStreamIndex' | 'SetSubtitleStreamIndex' | 'ToggleFullscreen' | 'DisplayContent' | 'GoToSearch' | 'DisplayMessage' | 'SetRepeatMode' | 'ChannelUp' | 'ChannelDown' | 'Guide' | 'ToggleStats' | 'PlayMediaSource' | 'PlayTrailers' | 'SetShuffleQueue' | 'PlayState' | 'PlayNext' | 'ToggleOsdMenu' | 'Play'; export type CreateApiSessionsSessionIdCommandCommandArgs = {sessionId: string, command: GeneralCommandType}; export type CreateApiSessionsSessionIdCommandCommandOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Issues a general command to a client. * * POST /Sessions/{sessionId}/Command/{command} */ export const createApiSessionsSessionIdCommandCommand = async (args: CreateApiSessionsSessionIdCommandCommandArgs, options?: CreateApiSessionsSessionIdCommandCommandOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Sessions/${encodeURIComponent(String(args.sessionId))}/Command/${encodeURIComponent(String(args.command))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };