# 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)

*** ** * ** ***


```
object SpatialMediaPlayer
```

<br />

*** ** * ** ***

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

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialMediaPlayer#setPointSourceParams(androidx.xr.runtime.Session,android.media.MediaPlayer,androidx.xr.scenecore.PointSourceParams,androidx.xr.scenecore.Entity)( session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session, mediaPlayer: https://developer.android.com/reference/android/media/MediaPlayer.html, params: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PointSourceParams, entity: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity )` Sets a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PointSourceParams` on a `https://developer.android.com/reference/android/media/MediaPlayer.html` instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialMediaPlayer#setSoundFieldAttributes(androidx.xr.runtime.Session,android.media.MediaPlayer,androidx.xr.scenecore.SoundFieldAttributes)( session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session, mediaPlayer: https://developer.android.com/reference/android/media/MediaPlayer.html, attributes: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SoundFieldAttributes )` Sets a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SoundFieldAttributes` on a `https://developer.android.com/reference/android/media/MediaPlayer.html` instance. |

## Public functions

### setPointSourceParams

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

```
fun setPointSourceParams(
    session: Session,
    mediaPlayer: MediaPlayer,
    params: PointSourceParams,
    entity: Entity
): Unit
```

Sets a `https://developer.android.com/reference/kotlin/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/kotlin/androidx/xr/scenecore/SpatialMediaPlayer#setSoundFieldAttributes(androidx.xr.runtime.Session,android.media.MediaPlayer,androidx.xr.scenecore.SoundFieldAttributes)` will apply since they are mutually exclusive.

| Parameters |
|---|---|
| `session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` | The current `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` instance. |
| `mediaPlayer: https://developer.android.com/reference/android/media/MediaPlayer.html` | The `https://developer.android.com/reference/android/media/MediaPlayer.html` instance on which to set the params |
| `params: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PointSourceParams` | The source params to be set. |
| `entity: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity` | The `https://developer.android.com/reference/kotlin/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)

```
fun setSoundFieldAttributes(
    session: Session,
    mediaPlayer: MediaPlayer,
    attributes: SoundFieldAttributes
): Unit
```

Sets a `https://developer.android.com/reference/kotlin/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/kotlin/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 |
|---|---|
| `session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` | The current `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` instance. |
| `mediaPlayer: https://developer.android.com/reference/android/media/MediaPlayer.html` | The `https://developer.android.com/reference/android/media/MediaPlayer.html` instance on which to set the attributes |
| `attributes: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SoundFieldAttributes` | The source attributes to be set. |