/** * @module MediaUtils * @description Utility functions for handling audio, video, and image operations in the browser. Provides methods for checking media type support, accessing user media devices, recording and manipulating media streams, converting between formats, and extracting metadata from media files. Includes helpers for screenshots, resizing, compression, and file downloads. * @example * ```typescript * import { MediaUtils } from 'houser-js-utils'; * * // Check if a media type is supported * const isSupported = MediaUtils.isMediaTypeSupported('video/mp4'); * * // Get all available cameras * const cameras = await MediaUtils.getCameras(); * * // Request camera access * const stream = await MediaUtils.requestCameraAccess(); * * // Take a screenshot from a video element * const screenshot = await MediaUtils.takeScreenshot(videoElement); * * // Resize an image file * const resized = await MediaUtils.resizeImage(imageFile, 800, 600); * ``` */ export declare const MediaUtils: { /** * Checks if the browser supports a specific media type. * @param type - Media type to check (e.g., 'video/mp4') * @returns True if the media type is supported * @example * ```typescript * MediaUtils.isMediaTypeSupported('video/mp4'); // true or false * MediaUtils.isMediaTypeSupported('audio/ogg'); // true or false * ``` */ isMediaTypeSupported(type: string): boolean; /** * Gets the supported media types for the current browser. * @returns Array of supported media types * @example * ```typescript * const supported = MediaUtils.getSupportedMediaTypes(); * console.log(supported); * ``` */ getSupportedMediaTypes(): string[]; /** * Gets the user's media devices (cameras, microphones, speakers). * @returns Promise that resolves with an array of media devices * @example * ```typescript * const devices = await MediaUtils.getMediaDevices(); * devices.forEach(device => console.log(device.kind, device.label)); * ``` */ getMediaDevices(): Promise; /** * Gets the user's camera devices. * @returns Promise that resolves with an array of camera devices * @example * ```typescript * const cameras = await MediaUtils.getCameras(); * cameras.forEach(cam => console.log(cam.label)); * ``` */ getCameras(): Promise; /** * Gets the user's microphone devices. * @returns Promise that resolves with an array of microphone devices * @example * ```typescript * const microphones = await MediaUtils.getMicrophones(); * microphones.forEach(mic => console.log(mic.label)); * ``` */ getMicrophones(): Promise; /** * Gets the user's speaker devices. * @returns Promise that resolves with an array of speaker devices * @example * ```typescript * const speakers = await MediaUtils.getSpeakers(); * speakers.forEach(spk => console.log(spk.label)); * ``` */ getSpeakers(): Promise; /** * Requests access to the user's camera. * @param constraints - Media constraints (default: { video: true }) * @returns Promise that resolves with a MediaStream * @example * ```typescript * const stream = await MediaUtils.requestCameraAccess(); * // Attach to video element * videoElement.srcObject = stream; * ``` */ requestCameraAccess(constraints?: MediaStreamConstraints): Promise; /** * Requests access to the user's microphone. * @param constraints - Media constraints (default: { audio: true }) * @returns Promise that resolves with a MediaStream * @example * ```typescript * const stream = await MediaUtils.requestMicrophoneAccess(); * // Attach to audio element * audioElement.srcObject = stream; * ``` */ requestMicrophoneAccess(constraints?: MediaStreamConstraints): Promise; /** * Requests access to the user's screen (screen sharing). * @param constraints - Media constraints (default: { video: true }) * @returns Promise that resolves with a MediaStream * @example * ```typescript * const stream = await MediaUtils.requestScreenAccess(); * // Attach to video element * videoElement.srcObject = stream; * ``` */ requestScreenAccess(constraints?: MediaStreamConstraints): Promise; /** * Stops all tracks in a MediaStream. * @param stream - MediaStream to stop * @example * ```typescript * MediaUtils.stopMediaStream(stream); * ``` */ stopMediaStream(stream: MediaStream): void; /** * Creates a MediaRecorder instance for recording a MediaStream. * @param stream - MediaStream to record * @param options - MediaRecorder options * @returns MediaRecorder instance * @example * ```typescript * const recorder = MediaUtils.createMediaRecorder(stream); * recorder.start(); * ``` */ createMediaRecorder(stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder; /** * Records a MediaStream to a Blob. * @param stream - MediaStream to record * @param options - MediaRecorder options * @returns Promise that resolves with the recorded Blob * @example * ```typescript * const blob = await MediaUtils.recordMediaStream(stream); * // Download the recording * MediaUtils.downloadBlob(blob, 'recording.webm'); * ``` */ recordMediaStream(stream: MediaStream, options?: MediaRecorderOptions): Promise; /** * Takes a screenshot of a video element and returns it as a PNG Blob. * @param video - Video element to capture * @returns Promise that resolves with the screenshot as a Blob * @throws {Error} If the canvas context cannot be obtained * @example * ```typescript * const screenshot = await MediaUtils.takeScreenshot(videoElement); * MediaUtils.downloadBlob(screenshot, 'screenshot.png'); * ``` */ takeScreenshot(video: HTMLVideoElement): Promise; /** * Converts a Blob to a base64 string. * @param blob - Blob to convert * @returns Promise that resolves with the base64 string (without the data URL prefix) * @example * ```typescript * const base64 = await MediaUtils.blobToBase64(blob); * console.log(base64); * ``` */ blobToBase64(blob: Blob): Promise; /** * Converts a base64 string to a Blob. * @param base64 - Base64 string to convert * @param type - MIME type of the Blob * @returns The converted Blob * @example * ```typescript * const blob = MediaUtils.base64ToBlob(base64String, 'image/jpeg'); * ``` */ base64ToBlob(base64: string, type: string): Blob; /** * Downloads a Blob as a file in the browser. * @param blob - Blob to download * @param filename - Name of the file * @example * ```typescript * MediaUtils.downloadBlob(blob, 'recording.webm'); * ``` */ downloadBlob(blob: Blob, filename: string): void; /** * Gets the duration of a video file in seconds. * @param file - Video file * @returns Promise that resolves with the duration in seconds * @example * ```typescript * const duration = await MediaUtils.getVideoDuration(videoFile); * console.log(`Duration: ${duration} seconds`); * ``` */ getVideoDuration(file: File): Promise; /** * Gets the dimensions of a video file. * @param file - Video file * @returns Promise that resolves with the video dimensions * @example * ```typescript * const { width, height } = await MediaUtils.getVideoDimensions(videoFile); * console.log(`Width: ${width}, Height: ${height}`); * ``` */ getVideoDimensions(file: File): Promise<{ width: number; height: number; }>; /** * Gets the duration of an audio file in seconds. * @param file - Audio file * @returns Promise that resolves with the duration in seconds * @example * ```typescript * const duration = await MediaUtils.getAudioDuration(audioFile); * console.log(`Audio duration: ${duration} seconds`); * ``` */ getAudioDuration(file: File): Promise; /** * Gets the dimensions of an image file. * @param file - Image file * @returns Promise that resolves with the image dimensions * @example * ```typescript * const { width, height } = await MediaUtils.getImageDimensions(imageFile); * console.log(`Image: ${width}x${height}`); * ``` */ getImageDimensions(file: File): Promise<{ width: number; height: number; }>; /** * Resizes an image file to fit within the specified maximum width and height. * @param file - Image file to resize * @param maxWidth - Maximum width * @param maxHeight - Maximum height * @returns Promise that resolves with the resized image as a Blob * @example * ```typescript * const resizedImage = await MediaUtils.resizeImage(imageFile, 800, 600); * MediaUtils.downloadBlob(resizedImage, 'resized.jpg'); * ``` */ resizeImage(file: File, maxWidth: number, maxHeight: number): Promise; /** * Compresses an image file to reduce its size. * @param file - Image file to compress * @param quality - Compression quality (0-1, default: 0.8) * @returns Promise that resolves with the compressed image as a Blob * @example * ```typescript * const compressedImage = await MediaUtils.compressImage(imageFile, 0.7); * MediaUtils.downloadBlob(compressedImage, 'compressed.jpg'); * ``` */ compressImage(file: File, quality?: number): Promise; };