# Gsy Custom View

自定义播放器 UI（继承 StandardGSYVideoPlayer）与自定义控制层：换 seekbar、加弹幕层、加清晰度切换、加投屏按钮等。

- Repository: https://github.com/CarGuo/GSYVideoPlayer (21524 stars)
- Category: Design
- License: Apache-2.0
- Last updated: 2026-10-10
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-custom-view -g -a claude-code -y`
Codex: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-custom-view -g -a codex -y`
Cursor: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-custom-view -g -a cursor -y`
Gemini CLI: `npx skills add CarGuo/GSYVideoPlayer --skill gsy-custom-view -g -a gemini-cli -y`

## Description

自定义播放器 UI（继承 StandardGSYVideoPlayer）与自定义控制层：换 seekbar、加弹幕层、加清晰度切换、加投屏按钮等。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# gsy-custom-view

## 继承层次

```
GSYTextureRenderView（渲染管理）
  └── GSYVideoView（状态机 / 生命周期）
        └── GSYVideoControlView（默认控制层：进度条/按钮）
              └── GSYVideoPlayer（触摸手势）
                    └── GSYBaseVideoPlayer（全屏/小屏切换）
                          ├── StandardGSYVideoPlayer（默认 UI）
                          └── NormalGSYVideoPlayer（无返回/无标题的简版）
```

自定义组件通常继承 [StandardGSYVideoPlayer](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java) 或 [NormalGSYVideoPlayer](../../gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/NormalGSYVideoPlayer.java)。

## 必须实现的三件事

### 1) 自定义布局 & id

覆写：
```java
@Override public int getLayoutId() { return R.layout.my_video_player; }
```
布局里必须包含（id 不能改）：
- `@id/surface_container`, , 放渲染 View（FrameLayout）
- 需要用到的默认控件（如 `@id/start`、`@id/progress`、`@id/current`、`@id/total`、`@id/bottom_progressbar`、`@id/thumb`、`@id/small_close`、`@id/back`、`@id/fullscreen`、`@id/loading`）, , 缺哪个哪个功能失效，编译不报错。

### 2) 覆写全屏 & 小屏组件类

关键：`getConstructor(Context, Boolean)` 是 SDK 内部反射拷贝出的全屏实例。**必须提供两个构造器**：

```java
public MyVideoPlayer(Context c) { super(c); }
public MyVideoPlayer(Context c, Boolean fullFlag) { super(c, fullFlag); }
public MyVideoPlayer(Context c, AttributeSet a) { super(c, a); }
```

R8 侧已在 [proguard-rules.pro](../../app/proguard-rules.pro) 保留：
```
-keep class * extends com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer {
    public <init>(android.content.Context);
    public <init>(android.content.Context, java.lang.Boolean);
}
```

### 3) 覆写 `showSmallVideo() / hideSmallVideo()`（如需要小窗）以及 `startWindowFullscreen()`（如要全屏样式差异）

## 常用重写点

The rest: https://github.com/CarGuo/GSYVideoPlayer/blob/HEAD/skills/12-gsy-custom-view/SKILL.md
