---
title: "togglePlayPause(_:)"
framework: nowplaying
role: symbol
role_heading: Type Method
path: "nowplaying/mediacommand/toggleplaypause(_:)"
---

# togglePlayPause(_:)

Creates a command that toggles between play and pause states.

## Declaration

```swift
static func togglePlayPause(_ action: @escaping () async throws -> Void) -> MediaCommand
```

## Parameters

- `action`: The closure the system calls to toggle playback.

## See Also

### Controlling playback

- [play(_:)](nowplaying/mediacommand/play(_:).md)
- [pause(_:)](nowplaying/mediacommand/pause(_:).md)
- [stop(_:)](nowplaying/mediacommand/stop(_:).md)
