carguo/gsyvideoplayer/11-gsy-compose-integration
Claude Code and agent skill by carguo/gsyvideoplayer
- community
Checking that the SKILL.md file is still in the repository.
在 Jetpack Compose 中通过 AndroidView 桥接 GSYVideoPlayer,覆盖列表、竖直短视频、生命周期管控。
Install
npx vskill@latest install carguo/gsyvideoplayer/11-gsy-compose-integrationSKILL.md
The same SKILL.md was published earlier as carguo/gsyvideoplayer/11-gsy-compose-integration.
gsy-compose-integration
模块
gsyVideoPlayer-compose 是 Compose 桥接层,两种模式并存:
| 模式 | 入口 | 说明 | |
|---|---|---|---|
| Wrapper(推荐上手) | GSYVideoPlayerView / GSYAnyVideoPlayerView | AndroidView 直接承载 StandardGSYVideoPlayer / 任意 NormalGSYVideoPlayer 子类,保留全部内置能力 | |
| Native(纯 Compose 控件) | rememberGSYPlayerController + GSYPlayerSurface + GSYDefaultControls | 只承载画面,控制层完全用 Compose 自绘 | |
| 通用工具 | LifecycleBridge | LifecycleEffect { event -> ... } 用于订阅宿主 Lifecycle |
Wrapper API:GSYVideoPlayerView
| 参数 | 类型 | 说明 | |
|---|---|---|---|
modifier | Modifier | 通常 Modifier.fillMaxWidth().aspectRatio(16f/9) | |
setUp | (StandardGSYVideoPlayer) -> Unit | 等价 GSYVideoOptionBuilder.build(player) | |
setUpKey | Any? = null | 非空时其变化会重新调用 setUp(典型:传 url) | |
autoReleaseOnDispose | Boolean = true | 离屏自动 player.release() | |
autoPauseResume | Boolean = true | 自动桥 Lifecycle:ON_PAUSE→GSYVideoManager.onPause()、ON_RESUME→onResume() | |
onPlayerCreated | (StandardGSYVideoPlayer) -> Unit | 拿到 player 实例的回调 |
Wrapper API:GSYAnyVideoPlayerView<T : NormalGSYVideoPlayer>
见 GSYAnyVideoPlayerView#L26-L35。相比 GSYVideoPlayerView 多出:
| 参数 | 类型 | 说明 | |
|---|---|---|---|
factory | (Context) -> T | 传自定义子类(如 ListGSYVideoPlayer、SampleControlVideo、DanmakuVideoPlayer) |
Native API:rememberGSYPlayerController
见 rememberGSYPlayerController#L26-L32:
| 参数 | 默认 | 说明 | |
|---|---|---|---|
url | null | 非空时内部 LaunchedEffect 触发 controller.setUp(...) | |
cacheWithPlay | false | 边播边缓 | |
title | "" | 标题(透传给底层 player) | |
autoPlay | false | attach 完成后自动 startPlayLogic | |
autoPauseResume | true | 自动订阅 Lifecycle(同 wrapper) |
返回 GSYPlayerController,可以再调 .play() / .pause() / .seekTo(ms) / .setSpeed(...) / .changeTextureViewShowType() / .setUp(url, cache, title, autoPlay) / .dispose();状态订阅走 GSYPlayerState(StateFlow<GSYPlayerState>),事件走 GSYPlayerEvent。
最小可运行示例
Wrapper 模式:
Native 模式:
生命周期最佳实践
Demo 对照
样例 hosts 全在 compose/host/。
v14.1.0 状态与接入
外部坐标为 io.github.carguo:gsyvideoplayer-compose:14.1.0(GitHub Packages 使用 com.shuyu)。IJK 使用方还需选择 ex_so 或独立 ABI 原生模块;完整组合见 DEPENDENCIES.md。
detachHost 只解绑 View 侧回调/tick,dispose 统一释放保留的 host;snapshot.bufferPercent 合并内核轮询与回调值。controller.changeTextureViewShowType() 在主线程更新当前内嵌/全屏比例。Compose Demo 共 25 项,新增折叠屏 BOOK/TABLETOP。详见 COMPOSE_USE.md。
snapshot.speed / stateFlow.speed 跟随当前 host 的倍速配置;每次 setUp 采用本次 builder 的倍速(默认 1f),不会隐式继承上一段视频的倍速。生命周期暂停在缓冲期间仍可恢复,迟到的缓冲通知不会覆盖暂停/恢复决定(#4267、#4268)。
常见坑
- Compose 频繁重组 →
AndroidView的factory只跑一次;不要把setUp放在factory里,放到updateblock,并用remember(url)做去重。 AndroidView内部布局要指定固定高度或aspectRatio,否则 SurfaceView 会 0 高度导致黑屏。- 竖直短视频 +
Pager:切页时用pagerState.currentPage触发state.play(url) / previousState.pause();释放放在DisposableEffect(pagerState)里。 - 与 Compose 主题深浅色切换:
GSYVideoPlayerCompose是原生 View 层,配色需要单独setBottomProgressBarDrawable等 API。
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/11-gsy-compose-integration/SKILL.md
Popularity
- Repository stars
- 21,490
- Repository forks
- 4,315
- 7-day trend score
- 50
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/carguo/gsyvideoplayer/11-gsy-compose-integration)