---
title: "dispatch(event:userInfo:completion:)"
framework: tvmlkit
role: symbol
role_heading: Instance Method
path: "tvmlkit/tvplayer/dispatch(event:userinfo:completion:)"
---

# dispatch(event:userInfo:completion:)

Dispatches custom playback events to the JavaScript environment.

## Declaration

```swift
func dispatch(event: TVPlaybackEvent, userInfo: (any TVPlaybackEventMarshaling)?, completion: (@Sendable (Bool) -> Void)? = nil)
```

```swift
func dispatch(event: TVPlaybackEvent, userInfo: (any TVPlaybackEventMarshaling)?) async -> Bool
```

## Parameters

- `event`: The custom playback event to be dispatched.
- `userInfo`: The user information for the custom event.
- `completion`: A block that is called after the event has been dispatched. Contains the information required to process the event’s results.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func dispatch(event: TVPlaybackEvent, userInfo: (any TVPlaybackEventMarshaling)?) async -> Bool For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Controlling Playback

- [next()](tvmlkit/tvplayer/next().md)
- [pause()](tvmlkit/tvplayer/pause().md)
- [previous()](tvmlkit/tvplayer/previous().md)
- [state](tvmlkit/tvplayer/state.md)
- [TVPlaybackState](tvmlkit/tvplaybackstate.md)
- [TVPlaybackEvent](tvmlkit/tvplaybackevent.md)
- [TVPlaybackEventMarshaling](tvmlkit/tvplaybackeventmarshaling.md)
- [TVPlaybackCustomEventUserInfo](tvmlkit/tvplaybackcustomeventuserinfo.md)
