09 gsy live and ads

From CarGuo/GSYVideoPlayer · View interactive version

09 gsy live and ads is an AI agent skill from the GitHub repository CarGuo/GSYVideoPlayer. 直播(RTMP/RTSP/HLS)、贴片广告 (PreRoll AD)、静音、切码率、无缝切源、切换过程保留最后一帧。

How to use this skill

Skill file

gsy-live-and-ads

直播接入要点

对 IJK 加 low-latency:通过 VideoOptionModel 注入 ffmpeg option,见 BasePlayerManager 与 GSYVideoManager.instance().setOptionModelList(list)。常用 option:analyzemaxduration=100、probesize=10240、flush_packets=1、fflags=nobuffer、packet-buffering=0、framedrop=1。

广告 AD

`startAD(...)` 关键调用序

  1. Activity 里持有主 player + AD player 两个 View;
  2. initADVideo() 装配(内部会连锁 OrientationUtils);
  3. startAD(adUrl, mainUrl) 播广告;
  4. AD complete → SDK 内部隐藏 AD player、start 主 player;
  5. 用户点"跳过"→ getGSYVideoADPlayer().onAutoCompletion()。

无缝切源 / 切码率

Exo 内核用 Exo2PlayerManager.setCurrentMediaSource(...) 或 Demo 里的 GSYExo2MediaPlayer.setMediaSources(...);Ijk 则重新 setUp + startPlayLogic。切换的过程中要求"不闪黑",用:

广告 / 主片全屏切换的两个陷阱

Demo 对照

v14.0.0 RTSP 与倍速

常见坑

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.