> For the complete documentation index, see [llms.txt](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/ios-sdk/api-reference/cemediaview.md).

# CEMediaView

## Overview

## Interface

### `delegate`

#### Declaration

```
@property (nonatomic, weak, nullable) id<CEMediaViewDelegate> delegate;
```

#### Discussion

Delegate which is notified by SDK when `CEMediaView` success/fail to updating its UI with an `CENativeAd`.

### `nativeAd`

#### Declaration

```
@property (nonatomic, strong, nullable) CENativeAd * nativeAd;
```

#### Discussion

Setting this property to an `CEMediaView` object updates its UI immediately. You can set this property

### `autoplayEnabled`

#### Declaration

```
@property (nonatomic, assign, getter = isAutoplayEnabled) BOOL autoplayEnabled
```

#### Discussion

Setting `autoplayEnabled` to `YES` means its associated native ad starts when `CEMediaView` is visible by user.

### `- initWithNativeAd:`

#### Declaration

```
- (nonnull instancetype) initWithNativeAd:(nonnull CENativeAd *)nativeAd;
```

#### Parameters

| name     | description                                               |
| -------- | --------------------------------------------------------- |
| nativeAd | A `CENativeAd` object containing ad information from SDK. |

#### Return Value

A `CEMediaView` instance.

#### Discussion

Use this initializer to create a `CEMediaView` instance when you have a loaded native ad. This is equivalent to calling `[CEMediaView initWithVideowProfile:]` with `CEVideoViewProfileDefaultProfile` and `[CEMediaView setNativeAd:]`.

### `- initWithVideowProfile:`

#### Declaration

```
- (nonnull instancetype) initWithVideowProfile:(CEVideoViewProfile)viewProfile;
```

#### Parameters

| name        | description                                                     |
| ----------- | --------------------------------------------------------------- |
| viewProfile | An option used to specify the layout and behavior of loaded ad. |

#### Return Value

A `CEMediaView` instance.

#### Discussion

Use this initializer if you are creating a `CEMediaView` in advance of your `CENativeAd` got loaded. The native ad can be assigned later when it is loaded.

### `- destroy`

#### Declaration

```
- (void) destroy;
```

#### Discussion

Use this method to destroy the cache ad in media view before discarding a `CEMediaView`.

### `- play`

#### Declaration

```
- (void) play;
```

#### Discussion

Invoking this method marks the ad as *allowed to play*. A ad starts when it is both marked as *allowed to play* and *visible* to users.

### `- stop`

#### Declaration

```
- (void) stop;
```

#### Discussion

Invoking this method marks the ad as *not allowed to play*. A ad stops immediately when `stop` is invoked and it will never resume until `play` is invoked.

### `- mute`

#### Declaration

```
- (void) mute;
```

#### Discussion

Invoking this method turns off the volume of the ad immediately.

### `- unmute`

#### Declaration

```
- (void) unmute;
```

#### Discussion

Invoking this method turns on the volume of the ad immediately.

### `- isMute`

#### Declaration

```
- (BOOL) isMute;
```

#### Return Value

`YES` if the ad is audible; otherwise, `NO`;

### `- setTouchEffectWithColor:`

#### Declaration

```
- (void)setTouchEffectWithColor:(nonnull UIColor *)highlightColor;
```

#### Parameters

| name           | description                                                       |
| -------------- | ----------------------------------------------------------------- |
| highlightColor | The color of a `CEMediaView` in `UIControlStateHighlighted` state |

#### Discussion

When touch effect is enabled through setting up `CEVideoViewProfileTouchEffect`, you can change the color of the `CEMediaView` with this method.

### `- setVideoReplayMode:`

#### Declaration

```
-(BOOL)setVideoReplayMode:(BOOL)isReplay DEPRECATED_ATTRIBUTE;
```

#### Discussion

This method is deprecated. You should set `CEVideoViewProfileAutoReplay` with `[CEMediaView initWithVideowProfile:]` instead.
