# SpatialMediaPlayer

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/SpatialMediaPlayer.kt+class:androidx.xr.scenecore.SpatialMediaPlayer) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public static class SpatialMediaPlayer
```

<br />

*** ** * ** ***

Provides spatial audio extensions on the framework `https://developer.android.com/reference/android/media/MediaPlayer.html` class.

## Summary

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SpatialMediaPlayer` | `https://developer.android.com/reference/androidx/xr/scenecore/SpatialMediaPlayer#INSTANCE()` |

| ### Public methods |
|---|---|
| `static final void` | `https://developer.android.com/reference/androidx/xr/scenecore/SpatialMediaPlayer#setPointSourceParams(androidx.xr.runtime.Session,android.media.MediaPlayer,androidx.xr.scenecore.PointSourceParams,androidx.xr.scenecore.Entity)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/media/MediaPlayer.html mediaPlayer, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PointSourceParams params, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity entity )` Sets a `https://developer.android.com/reference/androidx/xr/scenecore/PointSourceParams` on a `https://developer.android.com/reference/android/media/MediaPlayer.html` instance. |
| `static final void` | `https://developer.android.com/reference/androidx/xr/scenecore/SpatialMediaPlayer#setSoundFieldAttributes(androidx.xr.runtime.Session,android.media.MediaPlayer,androidx.xr.scenecore.SoundFieldAttributes)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/media/MediaPlayer.html mediaPlayer, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SoundFieldAttributes attributes )` Sets a `https://developer.android.com/reference/androidx/xr/scenecore/SoundFieldAttributes` on a `https://developer.android.com/reference/android/media/MediaPlayer.html` instance. |

## Public fields

### INSTANCE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public static @NonNull SpatialMediaPlayer INSTANCE
```

## Public methods

### setPointSourceParams

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public static final void setPointSourceParams(
    @NonNull Session session,
    @NonNull MediaPlayer mediaPlayer,
    @NonNull PointSourceParams params,
    @NonNull Entity entity
)
```

Sets a `https://developer.android.com/reference/androidx/xr/scenecore/PointSourceParams` on a `https://developer.android.com/reference/android/media/MediaPlayer.html` instance.

Must be called before `https://developer.android.com/reference/android/media/MediaPlayer.html#prepare()`. Not compatible with instances created by `https://developer.android.com/reference/android/media/MediaPlayer.html#create(android.content.Context, android.net.Uri)`. Only the params or attributes from the most recent call to this method or `https://developer.android.com/reference/androidx/xr/scenecore/SpatialMediaPlayer#setSoundFieldAttributes(androidx.xr.runtime.Session,android.media.MediaPlayer,androidx.xr.scenecore.SoundFieldAttributes)` will apply since they are mutually exclusive.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session` | The current `https://developer.android.com/reference/androidx/xr/runtime/Session` instance. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/media/MediaPlayer.html mediaPlayer` | The `https://developer.android.com/reference/android/media/MediaPlayer.html` instance on which to set the params |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PointSourceParams params` | The source params to be set. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity entity` | The `https://developer.android.com/reference/androidx/xr/scenecore/Entity` from which the sound will be played. |

### setSoundFieldAttributes

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public static final void setSoundFieldAttributes(
    @NonNull Session session,
    @NonNull MediaPlayer mediaPlayer,
    @NonNull SoundFieldAttributes attributes
)
```

Sets a `https://developer.android.com/reference/androidx/xr/scenecore/SoundFieldAttributes` on a `https://developer.android.com/reference/android/media/MediaPlayer.html` instance.

Must be called before `https://developer.android.com/reference/android/media/MediaPlayer.html#prepare()`. Not compatible with instances created by `https://developer.android.com/reference/android/media/MediaPlayer.html#create(android.content.Context, android.net.Uri)`. Only the attributes or params from the most recent call to this method or `https://developer.android.com/reference/androidx/xr/scenecore/SpatialMediaPlayer#setPointSourceParams(androidx.xr.runtime.Session,android.media.MediaPlayer,androidx.xr.scenecore.PointSourceParams,androidx.xr.scenecore.Entity)` will apply since they are mutually exclusive.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session` | The current `https://developer.android.com/reference/androidx/xr/runtime/Session` instance. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/media/MediaPlayer.html mediaPlayer` | The `https://developer.android.com/reference/android/media/MediaPlayer.html` instance on which to set the attributes |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/SoundFieldAttributes attributes` | The source attributes to be set. |