detachAudio()v4.0.528
Mutes a video element and inserts a corresponding audio element beside it.
Draft API: This API is experimental and may change.
detach-audio.tsimport {detachAudio , typeCodemodProject , typeJsxNodeReference } from '@remotion/codemods'; declare constproject :CodemodProject ; declare constnode :JsxNodeReference ; constresult = awaitdetachAudio ({project ,node , });console .log (result );
Supports recognized Remotion video imports. The audio element uses the same source and copies supported playback and timing props. This edits JSX; it does not extract or write an audio file.
Options
project
An in-memory CodemodProject. The input project is not mutated.
node
A JsxNodeReference from getJsxNodes() or a previous operation. It contains filePath and nodePath.
Return value
A promise resolving to an object with the following properties.
project
The updated project. Unchanged files and extra project fields are preserved.
changes
An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.
nodePathRemappings
An array of {filePath, oldNodePath, newNodePath} mappings. A null old path indicates an insertion; a null new path indicates removal. Apply these mappings to references from the input project. See node references.
insertedNode
The new audio element reference.
updatedNode
The muted video element reference.
Errors
Throws or rejects when the target cannot be resolved, the requested edit is unsupported, or an option is invalid. Failed edits leave the input project unchanged.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||