<!--
{
  "availability" : [
    "tvOS: 12.0.0 - 18.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "TVMLKit",
  "identifier" : "/documentation/TVMLKit/TVPlayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "TVMLKit"
    ],
    "preciseIdentifier" : "c:objc(cs)TVPlayer"
  },
  "title" : "TVPlayer"
}
-->

# TVPlayer

A customizable native media player used to control playback from the JavaScript player used in an Apple TV client-server app.

```
class TVPlayer
```

## Overview

You create a new `TVPlayer` object using your custom <doc://com.apple.documentation/documentation/AVFoundation/AVPlayer> object. You can then play media items that are associated with the JavaScript media player using the new player. For example, you can add gestures, overlays, and other custom features to your TV player.

## Topics

### Setting Up the Player

[`init(player: AVPlayer)`](/documentation/TVMLKit/TVPlayer/init(player:))

Creates a new customizable player from an existing player.

[`var player: AVPlayer`](/documentation/TVMLKit/TVPlayer/player)

The customizable media player.

[`var playlist: TVPlaylist?`](/documentation/TVMLKit/TVPlayer/playlist)

The playlist for the media player.

### Controlling Playback

[`func next()`](/documentation/TVMLKit/TVPlayer/next())

Plays the next media item in the playlist.

[`func pause()`](/documentation/TVMLKit/TVPlayer/pause())

Pauses the currently playing item.

[`func previous()`](/documentation/TVMLKit/TVPlayer/previous())

Plays the previous media item in the playlist.

[`var state: TVPlaybackState`](/documentation/TVMLKit/TVPlayer/state)

The current state of the player.

[`enum TVPlaybackState`](/documentation/TVMLKit/TVPlaybackState)

The possible states of a player.

[`func dispatch(event: TVPlaybackEvent, userInfo: (any TVPlaybackEventMarshaling)?, completion: ((Bool) -> Void)?)`](/documentation/TVMLKit/TVPlayer/dispatch(event:userInfo:completion:))

Dispatches custom playback events to the JavaScript environment.

[`struct TVPlaybackEvent`](/documentation/TVMLKit/TVPlaybackEvent)

Extend this structure to send your custom playback events to the JavaScript environment.

[`protocol TVPlaybackEventMarshaling`](/documentation/TVMLKit/TVPlaybackEventMarshaling)

A protocol used for sending and receiving information across the JavaScript bridge.

[`class TVPlaybackCustomEventUserInfo`](/documentation/TVMLKit/TVPlaybackCustomEventUserInfo)

The user information used in a custom playback event.

### Inspecting Media Items

[`func setCurrentMediaItem(toItemAtIndex: Int)`](/documentation/TVMLKit/TVPlayer/setCurrentMediaItem(toItemAtIndex:))

Sets the current media item to the designated media item.

[`var previousMediaItem: TVMediaItem?`](/documentation/TVMLKit/TVPlayer/previousMediaItem)

The previously selected media item.

[`var currentMediaItem: TVMediaItem?`](/documentation/TVMLKit/TVPlayer/currentMediaItem)

The currently selected media item.

[`var nextMediaItem: TVMediaItem?`](/documentation/TVMLKit/TVPlayer/nextMediaItem)

The next media item in the playlist.

### Instance Methods

[`func present(animated: Bool)`](/documentation/TVMLKit/TVPlayer/present(animated:))

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)