import { Expr, GpuFragmentParams } from '../../gpu/contract'; import { PropRef } from '../values'; /** What a media word returns: the GPU half of a definition. Spread it into `defineShader({...})`. */ export interface MediaSurfaceHalf { gpu: { fragment: (params: GpuFragmentParams) => Expr; }; } /** The fit-surface slots every media word shares. */ interface MediaFitSlots { /** The `compileTime` object-fit prop: `'cover'`, `'contain'`, `'fill'` or `'scale-down'`. */ fit: PropRef; /** How the sample is decoded. Always `'srgb-linear-alpha-cut'`: sRGB read as linear, letterbox made transparent. */ decode: 'srgb-linear-alpha-cut'; } /** * An image from a URL prop, fitted into the layer. * * The layer is transparent until the image loads, then shows it at its real aspect ratio. * Set `naturalSizeKey: {fromProp: 'url'}` on the definition so layout can measure the image. * `onError` receives load failures with the URL so you can phrase the message. * * @example * ```ts * ...imageMedia({src: p('url'), fit: p('objectFit'), decode: 'srgb-linear-alpha-cut', label: 'Photo'}) * ``` * @see videoMedia, webcamMedia */ export declare function imageMedia(opts: MediaFitSlots & { /** The URL prop. */ src: PropRef; /** A debug label for the texture, shown in GPU tooling. */ label: string; /** Called when the image fails to load. */ onError?: (error: unknown, url: string) => void; }): MediaSurfaceHalf; /** * A video from a URL prop, playing in the layer. * * The video plays muted and inline. `loop` is a boolean prop. `metadataTimeoutMs` is how long * to wait for the video's metadata before reporting a failure. Set * `naturalSizeKey: {fromProp: 'url'}` on the definition. `onError` tells you whether loading * (`'acquire'`) or playback (`'autoplay'`) failed. * * @example * ```ts * ...videoMedia({src: p('url'), fit: p('objectFit'), loop: p('loop'), decode: 'srgb-linear-alpha-cut', metadataTimeoutMs: 10000}) * ``` * @see imageMedia, webcamMedia */ export declare function videoMedia(opts: MediaFitSlots & { /** The URL prop. */ src: PropRef; /** The loop prop, synced to the video each frame. */ loop: PropRef; /** Milliseconds to wait for the video's metadata before giving up. */ metadataTimeoutMs: number; onError?: (error: unknown, info: { url: string | null; stage: 'acquire' | 'autoplay'; }) => void; }): MediaSurfaceHalf; /** * The user's camera, live in the layer. * * Asks for camera permission with your `constraints`. `mirror` is a boolean prop for a selfie * flip that updates instantly. This word also accepts `fit: 'none'` to show the feed at its * native pixel size. Set `naturalSizeKey: {fixed: ''}` on the definition and pass the * same key here. `onError` receives permission denials and playback failures. * * @example * ```ts * ...webcamMedia({fit: p('objectFit'), mirror: p('mirror'), decode: 'srgb-linear-alpha-cut', constraints: {video: {facingMode: 'user'}}, naturalSizeKey: 'webcam'}) * ``` * @see videoMedia, imageMedia */ export declare function webcamMedia(opts: MediaFitSlots & { /** The selfie-mirror boolean prop. */ mirror: PropRef; /** The `getUserMedia` constraints to request the camera with. */ constraints: MediaStreamConstraints; /** The key the definition's `naturalSizeKey: {fixed}` uses (a webcam has no URL). */ naturalSizeKey: string; onError?: (error: unknown, info: { url: string | null; stage: 'acquire' | 'autoplay'; }) => void; }): MediaSurfaceHalf; export {}; //# sourceMappingURL=media.d.ts.map