切换()v4.0.287
🌐 toggle()v4.0.287
切换 Remotion Studio 中的播放。如果当前组合正在播放,它将暂停。如果已暂停,它将开始播放。
🌐 Toggles playback in the Remotion Studio. If the composition is currently playing, it will pause. If it's paused, it will start playing.
该函数接受一个可选的事件参数,该参数可以是 React.SyntheticEvent 或 PointerEvent。这允许该函数直接用作事件处理程序。
🌐 The function accepts an optional event parameter which can be a React.SyntheticEvent or a PointerEvent. This allows the function to be used directly as an event handler.
示例
🌐 Examples
Toggle playback on button clickimport {toggle } from '@remotion/studio'; constToggleButton = () => { // Call with the event parameter for better browser audio autoplay return <button onClick ={(e ) =>toggle (e )}>Play/Pause</button >; };
Toggle playback programmaticallyimport {toggle } from '@remotion/studio'; // Call without event parametertoggle ();
另请参阅
🌐 See also