# Gsy Compose Integration

在 Jetpack Compose 中通过 AndroidView 桥接 GSYVideoPlayer，覆盖列表、竖直短视频、生命周期管控。

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

## Install

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

## Description

在 Jetpack Compose 中通过 AndroidView 桥接 GSYVideoPlayer，覆盖列表、竖直短视频、生命周期管控。

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

# gsy-compose-integration

## 模块

`gsyVideoPlayer-compose` 是 Compose 桥接层，两种模式并存：

| 模式 | 入口 | 说明 |
|---|---|---|
| **Wrapper**（推荐上手） | [GSYVideoPlayerView](../../gsyVideoPlayer-compose/src/main/java/com/shuyu/gsyvideoplayer/compose/wrapper/GSYVideoPlayerView.kt) / [GSYAnyVideoPlayerView](../../gsyVideoPlayer-compose/src/main/java/com/shuyu/gsyvideoplayer/compose/wrapper/GSYAnyVideoPlayerView.kt) | `AndroidView` 直接承载 `StandardGSYVideoPlayer` / 任意 `NormalGSYVideoPlayer` 子类，保留全部内置能力 |
| **Native**（纯 Compose 控件） | [rememberGSYPlayerController](../../gsyVideoPlayer-compose/src/main/java/com/shuyu/gsyvideoplayer/compose/native_/GSYPlayerSurface.kt) + [GSYPlayerSurface](../../gsyVideoPlayer-compose/src/main/java/com/shuyu/gsyvideoplayer/compose/native_/GSYPlayerSurface.kt) + [GSYDefaultControls](../../gsyVideoPlayer-compose/src/main/java/com/shuyu/gsyvideoplayer/compose/native_/GSYDefaultControls.kt) | 只承载画面，控制层完全用 Compose 自绘 |
| **通用工具** | [LifecycleBridge](../../gsyVideoPlayer-compose/src/main/java/com/shuyu/gsyvideoplayer/compose/common/LifecycleBridge.kt) | `LifecycleEffect { event -> ... }` 用于订阅宿主 Lifecycle |

## Wrapper API：`GSYVideoPlayerView`

见 [GSYVideoPlayerView#L28-L36](../../gsyVideoPlayer-compose/src/main/java/com/shuyu/gsyvideoplayer/compose/wrapper/GSYVideoPlayerView.kt)：

| 参数 | 类型 | 说明 |
|---|---|---|
| `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>`

The rest: https://github.com/CarGuo/GSYVideoPlayer/blob/HEAD/skills/11-gsy-compose-integration/SKILL.md
