Back to Remotion

toggle()

packages/docs/docs/studio/toggle.mdx

4.0.4821.0 KB
Original Source

toggle()<AvailableFrom v="4.0.287"/>

Toggles playback in the Remotion Studio. If the composition is currently playing, it will pause. If it's paused, it will start playing.

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

tsx
import {toggle} from '@remotion/studio';

const ToggleButton = () => {
  // Call with the event parameter for better browser audio autoplay

  return <button onClick={(e) => toggle(e)}>Play/Pause</button>;
};
tsx
import {toggle} from '@remotion/studio';

// Call without event parameter
toggle();

See also