Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions) Summary: [Ctors](https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#pubctors) \| [Methods](https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#inhmethods)

# CloudMediaProvider.CloudMediaSurfaceController

*** ** * ** ***

` public static abstract class CloudMediaProvider.CloudMediaSurfaceController `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.provider.CloudMediaProvider.CloudMediaSurfaceController |

<br />

*** ** * ** ***

Manages rendering the preview of media items on given instances of `https://developer.android.com/reference/android/view/Surface`.

The methods of this class are meant to be asynchronous, and should not block by performing any heavy operation.

Note that a single CloudMediaSurfaceController instance would be responsible for rendering multiple media items associated with multiple surfaces.

Note: For an optimal media preview experience in the photopicker, this class must be implemented by the Cloud Media Provider.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#CloudMediaSurfaceController()() ` |

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onConfigChange(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle config) ` Changes the configuration parameters for the CloudMediaSurfaceController. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onDestroy()() ` Indicates destruction of this CloudMediaSurfaceController object. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onMediaPause(int)(int surfaceId) ` Pauses the playback of the media associated with the given surface id. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onMediaPlay(int)(int surfaceId) ` Start playing the preview of the media associated with the given surface id. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onMediaSeekTo(int,%20long)(int surfaceId, long timestampMillis) ` Seeks the media associated with the given surface id to specified timestamp. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onPlayerCreate()() ` Creates any player resource(s) needed for rendering. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onPlayerRelease()() ` Releases any player resource(s) used for rendering. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onSurfaceChanged(int,%20int,%20int,%20int)(int surfaceId, int format, int width, int height) ` Indicates structural changes (format or size) in the `https://developer.android.com/reference/android/view/Surface` for rendering. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onSurfaceCreated(int,%20android.view.Surface,%20java.lang.String)(int surfaceId, https://developer.android.com/reference/android/view/Surface surface, https://developer.android.com/reference/java/lang/String mediaId) ` Indicates creation of the given `https://developer.android.com/reference/android/view/Surface` with given `surfaceId` for rendering the preview of a media item with given `mediaId`. |
| ` abstract void` | ` https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onSurfaceDestroyed(int)(int surfaceId) ` Indicates destruction of a `https://developer.android.com/reference/android/view/Surface` with given `surfaceId`. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### CloudMediaSurfaceController

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public CloudMediaSurfaceController ()
```

<br />

<br />

## Public methods

### onConfigChange

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onConfigChange (Bundle config)
```

Changes the configuration parameters for the CloudMediaSurfaceController.

<br />

| Parameters ||
|---|---|
| `config` | `Bundle`: the updated config to change to. This can include config changes for the following: - `https://developer.android.com/reference/android/provider/CloudMediaProviderContract#EXTRA_LOOPING_PLAYBACK_ENABLED` - `https://developer.android.com/reference/android/provider/CloudMediaProviderContract#EXTRA_SURFACE_CONTROLLER_AUDIO_MUTE_ENABLED` . This value cannot be `null`. <br /> |

### onDestroy

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onDestroy ()
```

Indicates destruction of this CloudMediaSurfaceController object.

This CloudMediaSurfaceController object should no longer be in use after this method has been called.

Note that it is possible for this method to be called directly without `https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onPlayerRelease()` being called, hence you should release any resources associated with this CloudMediaSurfaceController object, or perform any cleanup required in this method.

<br />

### onMediaPause

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onMediaPause (int surfaceId)
```

Pauses the playback of the media associated with the given surface id.

<br />

| Parameters ||
|---|---|
| `surfaceId` | `int`: id which uniquely identifies the `https://developer.android.com/reference/android/view/Surface` for rendering <br /> |

### onMediaPlay

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onMediaPlay (int surfaceId)
```

Start playing the preview of the media associated with the given surface id. If playback had previously been paused, playback will continue from where it was paused. If playback had been stopped, or never started before, playback will start at the beginning.

<br />

| Parameters ||
|---|---|
| `surfaceId` | `int`: id which uniquely identifies the `https://developer.android.com/reference/android/view/Surface` for rendering <br /> |

### onMediaSeekTo

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onMediaSeekTo (int surfaceId, 
                long timestampMillis)
```

Seeks the media associated with the given surface id to specified timestamp.

<br />

| Parameters ||
|---|---|
| `surfaceId` | `int`: id which uniquely identifies the `https://developer.android.com/reference/android/view/Surface` for rendering <br /> |
| `timestampMillis` | `long`: the timestamp in milliseconds from the start to seek to. Value is a non-negative duration in milliseconds. <br /> |

### onPlayerCreate

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onPlayerCreate ()
```

Creates any player resource(s) needed for rendering.

<br />

### onPlayerRelease

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onPlayerRelease ()
```

Releases any player resource(s) used for rendering.

<br />

### onSurfaceChanged

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onSurfaceChanged (int surfaceId, 
                int format, 
                int width, 
                int height)
```

Indicates structural changes (format or size) in the `https://developer.android.com/reference/android/view/Surface` for rendering.

This method is always called at least once, after `https://developer.android.com/reference/android/provider/CloudMediaProvider.CloudMediaSurfaceController#onSurfaceCreated(int,%20android.view.Surface,%20java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `surfaceId` | `int`: id which uniquely identifies the `https://developer.android.com/reference/android/view/Surface` for rendering <br /> |
| `format` | `int`: the new `https://developer.android.com/reference/android/graphics/PixelFormat` of the surface <br /> |
| `width` | `int`: the new width of the `https://developer.android.com/reference/android/view/Surface` <br /> |
| `height` | `int`: the new height of the `https://developer.android.com/reference/android/view/Surface` <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceHolder.Callback#surfaceChanged(android.view.SurfaceHolder,%20int,%20int,%20int)`

### onSurfaceCreated

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onSurfaceCreated (int surfaceId, 
                Surface surface, 
                String mediaId)
```

Indicates creation of the given `https://developer.android.com/reference/android/view/Surface` with given `surfaceId` for rendering the preview of a media item with given `mediaId`.

This is called immediately after the surface is first created. Implementations of this should start up whatever rendering code they desire.

Note that the given media item remains associated with the given surface id till the `https://developer.android.com/reference/android/view/Surface` is destroyed.

<br />

| Parameters ||
|---|---|
| `surfaceId` | `int`: id which uniquely identifies the `https://developer.android.com/reference/android/view/Surface` for rendering <br /> |
| `surface` | `Surface`: instance of the `https://developer.android.com/reference/android/view/Surface` on which the media item should be rendered. This value cannot be `null`. <br /> |
| `mediaId` | `String`: id which uniquely identifies the media to be rendered. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceHolder.Callback#surfaceCreated(android.view.SurfaceHolder)`

### onSurfaceDestroyed

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [R Extensions 3](https://developer.android.com/sdkExtensions)

```
public abstract void onSurfaceDestroyed (int surfaceId)
```

Indicates destruction of a `https://developer.android.com/reference/android/view/Surface` with given `surfaceId`.

This is called immediately before a surface is being destroyed. After returning from this call, you should no longer try to access this surface.

<br />

| Parameters ||
|---|---|
| `surfaceId` | `int`: id which uniquely identifies the `https://developer.android.com/reference/android/view/Surface` for rendering <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/SurfaceHolder.Callback#surfaceDestroyed(android.view.SurfaceHolder)`