export type BufferRequestDto = {When?: string | undefined, PositionTicks?: number | undefined, IsPlaying?: boolean | undefined, PlaylistItemId?: string | undefined}; export type CreateApiSyncPlayBufferingArgs = {body: BufferRequestDto}; export type CreateApiSyncPlayBufferingOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Notify SyncPlay group that member is buffering. * * POST /SyncPlay/Buffering */ export const createApiSyncPlayBuffering = async (args: CreateApiSyncPlayBufferingArgs, options?: CreateApiSyncPlayBufferingOptions) => { 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(/\/+$/, '')}/SyncPlay/Buffering${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 };