静音音频
你可以将 muted 属性传递给 <Audio>、<Video>、<OffthreadVideo>、<Html5Audio> 和 <Html5Video>,甚至可以随时间更改它。
🌐 You may pass in the muted prop to <Audio>, <Video>, <OffthreadVideo>, <Html5Audio> and <Html5Video> and even change it over time.
当 muted 为真时,该时间的音频将被省略。在以下示例中,我们将静音第 2 秒到第 4 秒之间的音轨。
🌐 When muted is true, audio will be omitted at that time. In the following example, we are muting the track between seconds 2 and 4.
import {AbsoluteFill , staticFile , useCurrentFrame , useVideoConfig } from 'remotion';
import {Html5Audio } from 'remotion';
export const MyComposition = () => {
const frame = useCurrentFrame ();
const {fps } = useVideoConfig ();
return (
<AbsoluteFill >
<Html5Audio src ={staticFile ('audio.mp3')} muted ={frame >= 2 * fps && frame <= 4 * fps } />
</AbsoluteFill >
);
};