03 gsy fullscreen orientation

From CarGuo/GSYVideoPlayer · View interactive version

03 gsy fullscreen orientation is an AI agent skill from the GitHub repository CarGuo/GSYVideoPlayer. 处理进入/退出全屏、屏幕旋转、竖屏视频自适应、系统旋转设置联动、反向横屏。

How to use this skill

Skill file

gsy-fullscreen-orientation

概念

核心 API

| 类 / 方法 | 位置 | 说明 |

|---|---|---|

| OrientationUtils(Activity, GSYBaseVideoPlayer) | OrientationUtils#L50-L52 | 主构造 |

| OrientationUtils(Activity, player, OrientationOption) | OrientationUtils#L54-L64 | 支持自定义旋转角度阈值 |

| setEnable(boolean) | OrientationUtils | 使能/失能自动旋转 |

| setRotateWithSystem(boolean) | OrientationUtils | 是否跟随系统"旋转开关" |

| setIsOnlyRotateLand(boolean) | OrientationUtils | true 时仅在横屏方向变化时响应 |

| resolveByClick() | OrientationUtils | 用户点全屏按钮时手动触发一次旋转 |

| backToProtVideo() | OrientationUtils | 返回键触发时把方向复位竖屏 |

| setIsPause(boolean) | OrientationUtils | 生命周期 pause/resume 桥接 |

| releaseListener() | OrientationUtils | onDestroy 释放监听 |

| startWindowFullscreen(Context, boolean, boolean) | GSYBaseVideoPlayer | 进入 window 全屏,返回克隆体 |

| GSYVideoManager.backFromWindowFull(Context) | GSYVideoManager#L82-L94 | 返回键统一处理 |

| GSYVideoManager.isFullState(Activity) | GSYVideoManager#L143-L151 | 当前是否全屏 |

`OrientationOption` 参数

| 字段 | 默认 | 作用 |

|---|---|---|

| normalPortraitAngleStart / End | 5 / 355 | 判定竖屏区间 |

| normalLandAngleStart / End | 85 / 95 | 判定正向横屏区间 |

| reverseLandAngleStart / End | 265 / 275 | 判定反向横屏区间 |

区间越大越"灵敏",太大会抖动。

关键调用序(详情页最佳实践)

  1. onCreate:orientationUtils = new OrientationUtils(this, player); orientationUtils.setEnable(false)(进页面不自动旋转)
  2. 全屏按钮点击:orientationUtils.resolveByClick() → player.startWindowFullscreen(this, true, true)
  3. onBackPressed:orientationUtils.backToProtVideo() → GSYVideoManager.backFromWindowFull(this)
  4. onPause:orientationUtils.setIsPause(true)
  5. onResume:orientationUtils.setIsPause(false)
  6. onDestroy:orientationUtils.releaseListener()

GSYBaseActivityDetail 已把 1/2/3/4/5/6 全套代码写好,直接继承最省事。

Demo 对照

v14.0.0 折叠屏示例

XML FoldDetailActivity 与 Compose FoldComposeActivity 按 FoldingFeature 实现 BOOK/TABLETOP 分屏、铰链分隔与全屏。XML 全屏克隆布局通过 LandLayoutVideo 传递姿态;普通全屏 API 不会自动给任意业务页面添加折叠布局。用法及测试注入边界见 RECENT_FEATURES.md。

常见坑

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.