Skip to main content

导入音频

将音频文件放入 public/ 文件夹,并使用 staticFile() 来引用它。 在你的组件中添加 <Html5Audio/> 标签以为其添加声音。

MyComp.tsx
import {AbsoluteFill, Html5Audio, staticFile} from 'remotion'; export const MyComposition = () => { return ( <AbsoluteFill> <Html5Audio src={staticFile('audio.mp3')} /> </AbsoluteFill> ); };

你也可以通过传递 URL 来添加远程音频:

🌐 You can also add remote audio by passing a URL:

MyComp.tsx
import {AbsoluteFill, Html5Audio} from 'remotion'; export const MyComposition = () => { return ( <AbsoluteFill> <Html5Audio src="https://example.com/audio.mp3" /> </AbsoluteFill> ); };

默认情况下,音频将从头开始播放,音量和长度为最大。 你可以通过添加更多的音频标签将多个曲目混合在一起。

🌐 By default, the audio will play from the start, at full volume and full length.
You can mix multiple tracks together by adding more audio tags.