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 GeneralCommand = {Name?: GeneralCommandType | undefined, ControllingUserId?: string | undefined, Arguments?: ({[key: string]: string} | null) | undefined}; export type CreateApiSessionsSessionIdCommandArgs = {sessionId: string, body: GeneralCommand}; export type CreateApiSessionsSessionIdCommandOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Issues a full general command to a client. * * POST /Sessions/{sessionId}/Command */ export const createApiSessionsSessionIdCommand = async (args: CreateApiSessionsSessionIdCommandArgs, options?: CreateApiSessionsSessionIdCommandOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Sessions/${encodeURIComponent(String(args.sessionId))}/Command${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };