{"record":{"id":"1ed63c15cb3c952b","repo":"remotion-dev/remotion","slug":"you-have-passed-a-volume-of-type-typeof-props-vo","errorCode":null,"errorMessage":"You have passed a volume of type ${typeof props.volume} to your <${component} /> component. Volume must be a number or a function with the signature '(frame: number) => number' undefined.","messagePattern":"You have passed a volume of type (.+?) to your <(.+?) /> component\\. Volume must be a number or a function with the signature '\\(frame: number\\) => number' undefined\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validate-media-props.ts","lineNumber":16,"sourceCode":"import type {VolumeProp} from './volume-prop.js';\n\nexport const validateMediaProps = (\n\tprops: {\n\t\tvolume: VolumeProp | undefined;\n\t\tplaybackRate: number | undefined;\n\t\tpreservePitch?: boolean | undefined;\n\t},\n\tcomponent: 'Html5Video' | 'Html5Audio' | 'Audio' | 'Video',\n) => {\n\tif (\n\t\ttypeof props.volume !== 'number' &&\n\t\ttypeof props.volume !== 'function' &&\n\t\ttypeof props.volume !== 'undefined'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`You have passed a volume of type ${typeof props.volume} to your <${component} /> component. Volume must be a number or a function with the signature '(frame: number) => number' undefined.`,\n\t\t);\n\t}\n\n\tif (typeof props.volume === 'number' && props.volume < 0) {\n\t\tthrow new TypeError(\n\t\t\t`You have passed a volume below 0 to your <${component} /> component. Volume must be between 0 and 1`,\n\t\t);\n\t}\n\n\tif (\n\t\ttypeof props.playbackRate !== 'number' &&\n\t\ttypeof props.playbackRate !== 'undefined'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`You have passed a playbackRate of type ${typeof props.playbackRate} to your <${component} /> component. Playback rate must a real number or undefined.`,\n\t\t);\n\t}","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validate-media-props.ts#L1-L34","documentation":"validateMediaProps throws a TypeError when the `volume` prop passed to <Audio>/<Video>/<Html5Audio>/<Html5Video> is not a number, not a function, and not undefined. Volume must be a number in [0,1] or a function (frame:number)=>number; anything else (string, object, null, boolean) is rejected.","triggerScenarios":"Passing volume=\"1\" (string from an input/URL), volume={null}, volume={true}, volume={{...}}, or an object from unvalidated props. Common when volume comes from user input, JSON config, or CMS data.","commonSituations":"Reading volume from a form field (string); deserializing config where volume was stored as string; passing a string '0.5'; loose-typed prop chains; copy-paste from CSS values.","solutions":["Coerce to number: `volume={Number(rawVolume)}`.","If volume is dynamic, pass a function: `volume={(f) => interpolate(f, [0, 30], [0, 1])}`.","Validate at the boundary: `typeof v === 'number' ? v : undefined`.","Omit the prop entirely (defaults apply) rather than passing a non-number."],"exampleFix":"// before\n<Audio src={url} volume={config.volume} /> // config.volume is \"0.8\"\n\n// after\n<Audio src={url} volume={Number(config.volume)} />","handlingStrategy":"type-guard","validationCode":"const v = typeof rawVolume === 'string' ? Number(rawVolume) : rawVolume;\nif (v != null && typeof v !== 'number' && typeof v !== 'function') {\n  throw new TypeError('invalid volume');\n}","typeGuard":"const isValidVolume = (v: unknown): v is number | ((f: number) => number) | undefined =>\n  v === undefined || typeof v === 'number' || typeof v === 'function';","tryCatchPattern":null,"preventionTips":["Coerce string volume to Number at the boundary.","Type volume as VolumeProp (number | (frame:number)=>number) in your props.","Validate config data before passing to <Audio>/<Video>."],"tags":["remotion","audio","video","volume","validation","typeerror","type-coercion"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}