# PlayerEmsgHandler

Artifact: [androidx.media3:media3-exoplayer-dash](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/dash/PlayerEmsgHandler.java+class:androidx.media3.exoplayer.dash.PlayerEmsgHandler)

*** ** * ** ***


```
@UnstableApi
public final class PlayerEmsgHandler implements Handler.Callback
```

<br />

*** ** * ** ***

Handles all emsg messages from all media tracks for the player.

This class will only respond to emsg messages which have schemeIdUri "urn:mpeg:dash:event:2012", and value "1"/"2"/"3". When it encounters one of these messages, it will handle the message according to Section 4.5.2.1 DASH -IF IOP Version 4.1:

- If both presentation time delta and event duration are zero, it means the media presentation has ended.
- Else, it will parse the message data from the emsg message to find the publishTime of the expired manifest, and mark manifest with publishTime smaller than that values to be expired.

In both cases, the DASH media source will be notified, and a manifest reload should be triggered.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler.PlayerEmsgCallback` Callbacks for player emsg events encountered during DASH live stream. |
| `public final inner class https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler.PlayerTrackEmsgHandler implements https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` Handles emsg messages for a specific track for the player. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler#PlayerEmsgHandler(androidx.media3.exoplayer.dash.manifest.DashManifest,androidx.media3.exoplayer.dash.PlayerEmsgHandler.PlayerEmsgCallback,androidx.media3.exoplayer.upstream.Allocator)( https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/DashManifest manifest, https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler.PlayerEmsgCallback playerEmsgCallback, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator allocator )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler#handleMessage(android.os.Message)(https://developer.android.com/reference/android/os/Message.html message)` |
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler.PlayerTrackEmsgHandler` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler#newPlayerTrackEmsgHandler()()` Returns a `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` that emsg messages could be written to. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler#release()()` Release this emsg handler. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler#updateManifest(androidx.media3.exoplayer.dash.manifest.DashManifest)(https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/DashManifest newManifest)` Updates the `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/DashManifest` that this handler works on. |

## Public constructors

### PlayerEmsgHandler

```
public PlayerEmsgHandler(
    DashManifest manifest,
    PlayerEmsgHandler.PlayerEmsgCallback playerEmsgCallback,
    Allocator allocator
)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/DashManifest manifest` | The initial manifest. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/PlayerEmsgHandler.PlayerEmsgCallback playerEmsgCallback` | The callback that this event handler can invoke when handling emsg messages that generate DASH media source events. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator allocator` | An `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator` from which allocations can be obtained. |

## Public methods

### handleMessage

```
public boolean handleMessage(Message message)
```

### newPlayerTrackEmsgHandler

```
public PlayerEmsgHandler.PlayerTrackEmsgHandler newPlayerTrackEmsgHandler()
```

Returns a `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` that emsg messages could be written to.

### release

```
public void release()
```

Release this emsg handler. It should not be reused after this call.

### updateManifest

```
public void updateManifest(DashManifest newManifest)
```

Updates the `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/DashManifest` that this handler works on.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/DashManifest newManifest` | The updated manifest. |