---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/ios/video-control.md
  - https://ads.yandex.com/helpcenter/ru/dev/ios/video-control.md
  - https://ads.yandex.com/helpcenter/zh/dev/ios/video-control.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/zh/llms.txt

# 重新定义视频中的界面元素

SDK 使您能够重新定义与系统交互的界面元素。尤其是以下元素：

- 控制视频进度 (`VideoProgress`)；
- 启用/禁用视频声音（更改设计和位置）。

## 1. 重新定义 VideoProgress {#video-progress}

```swift
class CustomVideoProgressControl: UIProgressView, NativeVideoPlaybackProgressControl {

    /// 配置具有位置和持续时间的进度控件。
    /// - 参数：
    ///   - position：当前 OutStream 广告的位置。
    ///   - duration: 当前 OutStream 广告的持续时间。
    func configure(withPosition position: TimeInterval, duration: TimeInterval) {
    }

    /// 重置视频进度。
    func reset() {
    }
}
```

## 2. 重新定义声音开/关按钮 {#video-playback}

```swift
class CustomVideoPlaybackMuteControl: UIButton, NativeVideoPlaybackMuteControl {
    /// 代理会收到有关视频播放静音控制事件的通知。
    var delegate: NativeVideoPlaybackMuteControlDelegate?

    /// 配置带有指定 isMuted 标志的静音控制。
    /// - 参数 isMuted：用于设置静音/取消静音状态的标志。
    func configure(withIsMuted isMuted: Bool) {
    }

    /// 配置带有指定 isHidden 标志的静音控件。
    /// - 参数 isHidden：用于设置静音/取消静音状态的标志。
    func configure(withIsHidden isHidden: Bool) {
    }
}
```

## 3. 创建并链接带有控件的对象

1. 完成重新定义后，创建一个对象。

   ```swift
   let customVideoPlaybackControls = NativeVideoPlaybackControls(
       CustomVideoProgressControl(),
       CustomVideoPlaybackMuteControl()
   )
   ```
2. 将对象链接到 `YMANativeMediaView`。

   ```swift
   customVideoPlaybackControls.setupVideoPlaybackControls(to: YMANativeMediaView)
   ```

