Skills

Gsy Custom View

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

Install

npx skills add CarGuo/GSYVideoPlayer --skill gsy-custom-view -g -a claude-code -y
Repository
CarGuo/GSYVideoPlayer21.5k
Category
Design
Updated
26d ago
License
Apache-2.0
Context cost
Lightabout 968 tokens
Runs scripts
No, instructions only

What it does

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

gsy-custom-view

继承层次

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

自定义组件通常继承 StandardGSYVideoPlayer 或 NormalGSYVideoPlayer。

必须实现的三件事

1) 自定义布局 & id

覆写:

@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 内部反射拷贝出的全屏实例。必须提供两个构造器:

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 保留:

-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()(如要全屏样式差异)

常用重写点

Read the whole SKILL.md on GitHub

More in Design