carguo/gsyvideoplayer/11-gsy-compose-integration

Claude Code and agent skill by carguo/gsyvideoplayer

Trust tier 2
  • community
LLM review pending
Source check pending

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-integration

SKILL.md

The same SKILL.md was published earlier as carguo/gsyvideoplayer/11-gsy-compose-integration.

gsy-compose-integration

模块

gsyVideoPlayer-compose 是 Compose 桥接层,两种模式并存:

模式入口说明
Wrapper(推荐上手)GSYVideoPlayerView / GSYAnyVideoPlayerViewAndroidView 直接承载 StandardGSYVideoPlayer / 任意 NormalGSYVideoPlayer 子类,保留全部内置能力
Native(纯 Compose 控件)rememberGSYPlayerController + GSYPlayerSurface + GSYDefaultControls只承载画面,控制层完全用 Compose 自绘
通用工具LifecycleBridgeLifecycleEffect { event -> ... } 用于订阅宿主 Lifecycle

Wrapper API:GSYVideoPlayerView

见 GSYVideoPlayerView#L28-L36:

参数类型说明
modifierModifier通常 Modifier.fillMaxWidth().aspectRatio(16f/9)
setUp(StandardGSYVideoPlayer) -> Unit等价 GSYVideoOptionBuilder.build(player)
setUpKeyAny? = null非空时其变化会重新调用 setUp(典型:传 url)
autoReleaseOnDisposeBoolean = true离屏自动 player.release()
autoPauseResumeBoolean = 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:

参数默认说明
urlnull非空时内部 LaunchedEffect 触发 controller.setUp(...)
cacheWithPlayfalse边播边缓
title""标题(透传给底层 player)
autoPlayfalseattach 完成后自动 startPlayLogic
autoPauseResumetrue自动订阅 Lifecycle(同 wrapper)

返回 GSYPlayerController,可以再调 .play() / .pause() / .seekTo(ms) / .setSpeed(...) / .changeTextureViewShowType() / .setUp(url, cache, title, autoPlay) / .dispose();状态订阅走 GSYPlayerState(StateFlow<GSYPlayerState>),事件走 GSYPlayerEvent。

最小可运行示例

Wrapper 模式:

kotlin
GSYVideoPlayerView(
modifier = Modifier.fillMaxWidth().aspectRatio(16f/9),
setUpKey = url,
setUp = { player ->
GSYVideoOptionBuilder()
.setUrl(url)
.setCacheWithPlay(true)
.setVideoTitle("demo")
.setIsTouchWiget(true)
.setAutoFullWithSize(true)
.build(player)
player.startPlayLogic()
}
)

Native 模式:

kotlin
val controller = rememberGSYPlayerController(url = url, autoPlay = true)
Box(Modifier.fillMaxWidth().aspectRatio(16f/9)) {
GSYPlayerSurface(controller = controller, modifier = Modifier.matchParentSize())
GSYDefaultControls(controller = controller)
}

生命周期最佳实践

kotlin
val lifecycle = LocalLifecycleOwner.current.lifecycle
DisposableEffect(lifecycle) {
val obs = LifecycleEventObserver { _, e ->
when (e) {
Lifecycle.Event.ON_PAUSE -> state.pause()
Lifecycle.Event.ON_RESUME -> state.resumeIfNeeded()
Lifecycle.Event.ON_DESTROY-> state.release()
else -> Unit
}
}
lifecycle.addObserver(obs)
onDispose { lifecycle.removeObserver(obs) }
}

Demo 对照

场景Activity
原生桥接示例DetailNativeActivity / BasicWrapperActivity / FullFeatureNativeActivity
广告 + 主片(列表内)AdInListComposeActivity
列表 + 全屏ListWithFullscreenActivity / ListPlayNativeActivity / AutoPlayListActivity
抖音式竖屏VerticalShortVideoComposeActivity
滤镜DetailFilterComposeActivity
无缝切源 / Exo 切源SwitchSeamlessComposeActivity / ExoSwitchSourceComposeActivity / SwitchUrlActivity
字幕SubtitleComposeActivity
弹幕DanmakuComposeActivity
缓存 / 下载CacheDownloadComposeActivity
硬解 / MediaCodecMediaCodecComposeActivity
悬浮小窗FloatingWindowComposeActivity
音频独立AudioOnlyComposeActivity
多类型混排MoreTypeComposeActivity
多窗口并行MultiWindowActivity / MultiWindowParallelComposeActivity
本地文件LocalFileComposeActivity
自定义主题CustomControlsThemeComposeActivity
WebView 详情WebDetailComposeActivity

样例 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 里,放到 update block,并用 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/carguo/gsyvideoplayer/11-gsy-compose-integration/badge)](https://verified-skill.com/skills/carguo/gsyvideoplayer/11-gsy-compose-integration)

Something wrong with this skill or its page? Tell us.