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 CreateApiSessionsCapabilitiesArgs = {id?: (string | null) | undefined, playableMediaTypes?: (Array | null) | undefined, supportedCommands?: (Array | null) | undefined, supportsMediaControl?: boolean | undefined, supportsSync?: boolean | undefined, supportsPersistentIdentifier?: boolean | undefined}; export type CreateApiSessionsCapabilitiesOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Updates capabilities for a device. * * POST /Sessions/Capabilities */ export const createApiSessionsCapabilities = async (args: CreateApiSessionsCapabilitiesArgs, options?: CreateApiSessionsCapabilitiesOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.id != null) query.append("id", String(args.id)) for (const item of args.playableMediaTypes ?? []) query.append("playableMediaTypes", String(item)) for (const item of args.supportedCommands ?? []) query.append("supportedCommands", String(item)) if (args.supportsMediaControl != null) query.append("supportsMediaControl", String(args.supportsMediaControl)) if (args.supportsSync != null) query.append("supportsSync", String(args.supportsSync)) if (args.supportsPersistentIdentifier != null) query.append("supportsPersistentIdentifier", String(args.supportsPersistentIdentifier)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Sessions/Capabilities${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 };