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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://intowow.gitbook.io/crystalexpress-documentation-v3-x/ios-sdk/api-reference/cemediaview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
