GSYVideoPlayer

csd
csd
2小时前发布 /正在检测是否收录...
广告 广告 广告 广告 广告 广告 广告 广告 广告 广告

项目介绍

视频播放器(IJKplayer、ExoPlayer、MediaPlayer),HTTPS支持,支持弹幕,支持滤镜、水印、gif截图,片头广告、中间广告,多个同时播放,支持基本的拖动,声音、亮度调节,支持边播边缓存,支持视频本身自带rotation的旋转(90,270之类),重力旋转与手动旋转的同步支持,支持列表播放 ,直接添加控件为封面,列表全屏动画,视频加载速度,列表小窗口支持拖动,动画效果,调整比例,多分辨率切换,支持切换播放器,进度条小窗口预览,其他一些小动画效果,rtsp、concat、mpeg。项目解析:

项目详情

Click to see the English version

图片[1] - GSYVideoPlayer - 陆伍博客 - 你的互联网资源库

支持 IJKPlayer、 Media3(EXOPlayer2)、MediaPlayer、AliPlayer,实现了多功能的视频播放器。 (请仔细阅读下方各项说明,大多数问题可在下方找到解答)。

* 鸿蒙版本openharmony-tpc/GSYVideoPlayer

如果克隆太慢或者图片看不到,可尝试从以下地址同步

类型功能
缓存边播边缓存,使用了AndroidVideoCache;Media3(ExoPlayer)使用SimpleCache。
协议h263\4\5、Https、concat、rtsp、hls、rtmp、crypto、mpeg等等。(ijk模式格式支持)
滤镜简单滤镜(马赛克、黑白、色彩过滤、高斯、模糊、模糊等等20多种)、动画、(水印、画面多重播放等)。
帧图视频第一帧、视频帧截图功能、播放器 UI 组合截图功能,视频生成gif功能。
播放列表播放、列表连续播放、重力旋转与手动旋转、视频本身rotation旋转属性、快播和慢播、网络视频加载速度。
画面调整显示比例:默认、16:9、4:3、填充;播放时旋转画面角度(0,90,180,270);镜像旋转。
内核IJKPlayer、Media3(EXOPlayer)、MediaPlayer、AliPlayer切换、自定义内核
布局全屏与非全屏两套布局切换、没有任何操作控件的纯播放支持、弹幕功能、继承自定义任何布局。
播放单例播放、多个同时播放、视频列表滑动自动播放、列表切换详情页面无缝播放。
窗口小窗口、多窗体下(包括桌面)的小窗口播放。
广告片头广告、跳过广告支持、中间插入广告功能。
字幕支持通用外挂字幕 Overlay,SRT/WebVTT 可跨 IJK、Media3(EXOPlayer)、MediaPlayer 等内核使用;Media3 内嵌字幕可桥接到同一套 UI。说明。
dashmedia3(exo2) 模式支持dash;Demo 支持 HLS master / DASH MPD 自适应清晰度轨道切换。
stream支持元数据播放
适配 16kex_so 适配 16K Page Size
openssl目前 ex_so 的 arm64/x86_64 使用 openssl 1.1.1w
FFmpeg目前 ex_so 的 arm64-v8a / armeabi-v7a / x86_64 均使用 FFmpeg n5.1.10
FFmpeg目前 ex_so 的 arm64-v8a / armeabi-v7a / x86_64 均支持 G711a(pcm_alaw)
投屏可选 gsyvideoplayer-cast DLNA/UPnP 模块,基于 jUPnP 3.0.3;核心只保留协议无关的 CastCapability / CastProvider / CastSession SPI,不再默认引入 Jetty。说明。
更多暂停前后台切换不黑屏;多 URL 清晰度切换;Exo HLS/DASH 自适应清晰度;无缝切换支持;完成后保留最后一帧 Demo;进度条 WebVTT 小窗口预览。
自定义可自定义渲染层、自定义管理层、自定义播放层(控制层)、自定义缓存层。

Maven Central Version
图片[2] - GSYVideoPlayer - 陆伍博客 - 你的互联网资源库
Build Status
Github Actions

[]()
GitHub stars
GitHub forks
GitHub issues
GitHub License

[]()
Star
图片[3] - GSYVideoPlayer - 陆伍博客 - 你的互联网资源库

公众号掘金知乎CSDN简书
GSYTech点我点我点我点我

图片[4] - GSYVideoPlayer - 陆伍博客 - 你的互联网资源库

--------------Demo APK 下载地址---------------

一、使用依赖

目前有三种托管方式:

  • MavenCentral : 11.0.0 版本以后才有,所有基类包都发布托管在这里
  • Github Package : 9.1.0 版本开始才有, 但是 11.0.0 之前, GSYIjkJava 的基础依赖还是在托管在 jitpack
  • Jitpack IO :依然会发布,但是存在托管平台随机丢包

--- 版本更新说明 --- 。

--- 近期播放能力说明 --- 。

1、mavenCentral 引用(推荐)

由于 jitpack 不断丢包,目前已迁移至 MavenCentral,使用方式如下:

First 添加

allprojects {
repositories {
///...
mavenCentral()
maven { url "https://maven.aliyun.com/repository/public" }
}
}

你可以选择下面三种的其中一种,在module下的build.gradle添加。

A、直接引入

 //完整版引入

implementation 'io.github.carguo:gsyvideoplayer:13.2.1'

//是否需要AliPlayer模式
implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.2.1'

//是否需要 DLNA/UPnP 投屏(可选,minSdk 26)
implementation 'io.github.carguo:gsyvideoplayer-cast:13.2.1'

B、添加java和你想要的so支持:

 implementation 'io.github.carguo:gsyvideoplayer-java:13.2.1'

 //是否需要ExoPlayer模式
 implementation 'io.github.carguo:gsyvideoplayer-exo2:13.2.1'

 //可选直接依赖;exo2 已经通过 api 传递 RTMP 模块
 implementation 'io.github.carguo:gsyvideoplayer-rtmp:13.2.1'

 //可选 DLNA/UPnP 投屏实现(minSdk 26);默认播放器不包含 Jetty
 implementation 'io.github.carguo:gsyvideoplayer-cast:13.2.1'

 //是否需要AliPlayer模式
 implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.2.1'

 //根据你的需求ijk模式的so
 implementation 'io.github.carguo:gsyvideoplayer-arm64:13.2.1'
 implementation 'io.github.carguo:gsyvideoplayer-armv7a:13.2.1'
 implementation 'io.github.carguo:gsyvideoplayer-armv5:13.2.1'
 implementation 'io.github.carguo:gsyvideoplayer-x86:13.2.1'
 implementation 'io.github.carguo:gsyvideoplayer-x64:13.2.1'

C、支持其他格式协议的(mpeg,rtsp, concat、crypto协议,支持 16k Page Size)

A、B普通版本支持263/264/265等,对于mpeg编码会有声音无画面情况。
C 引入的so支持mpeg编码和其他补充协议,但是so包相对变大。

 implementation 'io.github.carguo:gsyvideoplayer-java:13.2.1'

 //是否需要ExoPlayer模式
 implementation 'io.github.carguo:gsyvideoplayer-exo2:13.2.1'

 //是否需要AliPlayer模式
 implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.2.1'

 //更多ijk的编码支持
 implementation 'io.github.carguo:gsyvideoplayer-ex_so:13.2.1'

D、Jetpack Compose 支持(可选)

gsyvideoplayer-compose 模块从 v13.1.0 开始随主版本发布。你可以像其它模块一样从 Maven Central / GitHub Packages 引用,也可以在本仓库内开发时继续使用 implementation project(":gsyVideoPlayer-compose") 直接引用源码模块。

🛠 工具链说明: 该模块在 CI 上用 JDK 21 验证(.github/workflows/*.yml 中 actions/setup-java 的 java-version: 21),本地用 JDK 17 验证(模块自身在 gsyVideoPlayer-compose/build.gradle 把 sourceCompatibility / targetCompatibility / jvmTarget 钉在 17)。两者都可以,只要本机 JDK ≥ 17 就能跑通 Kotlin 2.0.21 + AGP 8.6.1。

新增 gsyvideoplayer-compose 模块,在保留全部内核与 UI 能力的前提下,提供 Compose 接入:

  • Wrapper 模式:一行 GSYVideoPlayerView { ... } 把 StandardGSYVideoPlayer 直接嵌入 Compose 屏,自动桥接 Lifecycle 与 release;新增可选 setUpKey: Any? 参数,仅当数据标识变化时才重跑 setUp(幂等)。
  • Native 模式:GSYComposeHostPlayer + GSYPlayerController 暴露 GSYPlayerSnapshot 状态流,外加 events: SharedFlow 一次性边沿事件(Prepared / AutoComplete / Error)。控制层可完全用 Compose 自绘,画面与多内核仍走原 GSY 渲染管线。旧的 setOnError / setOnComplete / setOnPrepared 仍可用,但已 @Deprecated,推荐迁移到 Flow。
// Maven Central:
implementation 'io.github.carguo:gsyvideoplayer-compose:13.2.1'

// 本地源码开发:
implementation project(':gsyVideoPlayer-compose')
// compose-bom 由模块 api 透出,使用方仍按自身工程版本管理 androidx.compose.* 即可

详见 doc/COMPOSE_USE.md,App 模块下 Compose Demo 入口提供 24 个可运行的 Compose Activity —— 覆盖 Wrapper 基础 / Native 详情·列表·多窗口·自动连播·切流·无缝切换 / P5 招牌差异化能力(滤镜、缓存下载、前贴片广告、字幕、自绘弹幕、EXO 多源、Wrapper 真并行多窗口)/ P5-2 现代 App 高频形态(竖屏短视频、悬浮窗、多类型列表、视频+WebView、纯音频、自定义 URL/本地文件、MediaCodec 硬解切换、主题化自绘 controls)。DemoSamples.kt 是共享的 data object 测试 URL 集合,不是可运行的 Activity。当前能力缺口与分轮推进路线图已归档到 doc/COMPOSE_BACKLOG.md。

2、Github Package 依赖方式(推荐)

由于 Jitpack 经常存在历史包随机丢失问题,所以新增 Github Package 依赖方式,使用方式如下:

不过 github package 访问需要 token 去 access 比较麻烦,但是胜在稳定
allprojects {
repositories {
        //...
maven {
url 'https://maven.pkg.github.com/CarGuo/GSYVideoPlayer'

// You can also use your own GitHub account and token
// For convenience, I have provided a token for an infrequently used account here
credentials {
// your github name
username = 'carsmallguo'
// your github generate new token
password = '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'
}
}
maven {
url "https://maven.aliyun.com/repository/public"
}
mavenCentral()

}
}

理论上就是右上角头像 - Settings - Developer Settings - Personal access tokens - tokens (classic) -
Generate new token(classic)- read:packages
记得过期时间选择永久

小提示:仓库根目录 build.gradle 现已支持从 Gradle 属性或环境变量读取 GitHub Packages 凭据,无需把自己的 token 写进源码:

# ~/.gradle/gradle.properties(推荐本地使用)
githubReadUser=
githubReadToken=

或在 CI 上:

export GITHUB_READ_USER=
export GITHUB_READ_TOKEN=

仓库里仍内置 carsmallguo / ghp_... 这一对兜底凭据,便于第一次 clone 即可构建;它随时可能被撤销,建议优先用你自己的 token。

你可以选择下面三种的其中一种,在module下的build.gradle添加。

A、直接引入

 //完整版引入
 implementation 'com.shuyu:gsyvideoplayer:13.2.1'

 //是否需要AliPlayer模式
 implementation 'com.shuyu:gsyvideoplayer-aliplay:13.2.1'

 //是否需要 DLNA/UPnP 投屏(可选,minSdk 26)
 implementation 'com.shuyu:gsyvideoplayer-cast:13.2.1'

B、添加java和你想要的so支持:

 implementation 'com.shuyu:gsyvideoplayer-java:13.2.1'

 //是否需要ExoPlayer模式
 implementation 'com.shuyu:gsyvideoplayer-exo2:13.2.1'

 //可选直接依赖;exo2 已经通过 api 传递 RTMP 模块
 implementation 'com.shuyu:gsyvideoplayer-rtmp:13.2.1'

 //可选 DLNA/UPnP 投屏实现(minSdk 26);默认播放器不包含 Jetty
 implementation 'com.shuyu:gsyvideoplayer-cast:13.2.1'

 //是否需要AliPlayer模式
 implementation 'com.shuyu:gsyvideoplayer-aliplay:13.2.1'

 //根据你的需求ijk模式的so
 implementation 'com.shuyu:gsyvideoplayer-armv5:13.2.1'
 implementation 'com.shuyu:gsyvideoplayer-armv7a:13.2.1'
 implementation 'com.shuyu:gsyvideoplayer-arm64:13.2.1'
 implementation 'com.shuyu:gsyvideoplayer-x86:13.2.1'
 implementation 'com.shuyu:gsyvideoplayer-x64:13.2.1'

C、支持其他格式协议的(mpeg,rtsp, concat、crypto协议,支持 16k Page Size)

A、B普通版本支持263/264/265等,对于mpeg编码会有声音无画面情况。
C 引入的so支持mpeg编码和其他补充协议,但是so包相对变大。

 implementation 'com.shuyu:gsyvideoplayer-java:13.2.1'

 //是否需要ExoPlayer模式
 implementation 'com.shuyu:gsyvideoplayer-exo2:13.2.1'

 //是否需要AliPlayer模式
 implementation 'com.shuyu:gsyvideoplayer-aliplay:13.2.1'

 //更多ijk的编码支持
 implementation 'com.shuyu:gsyvideoplayer-ex_so:13.2.1'

D、Jetpack Compose 支持(可选)

 implementation 'com.shuyu:gsyvideoplayer-compose:13.2.1'

3、Jitpack 引入方法(会继续发布,但不是很推荐)

历史包可能会出现随机丢包,而且还不好补充,可见 #4144:

First、在project下的build.gradle添加

allprojects {
repositories {
        //...
maven { url 'https://jitpack.io' }
maven { url "https://maven.aliyun.com/repository/public" }
mavenCentral()
}
}

你可以选择下面三种的其中一种,在module下的build.gradle添加。

A、直接引入

 //完整版引入

 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer:v13.2.1'

 //是否需要AliPlayer模式
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.2.1'

 //是否需要 DLNA/UPnP 投屏(可选,minSdk 26)
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-cast:v13.2.1'

B、添加java和你想要的so支持:

 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-java:v13.2.1'

 //是否需要ExoPlayer模式
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-exo2:v13.2.1'

 //可选 DLNA/UPnP 投屏实现(minSdk 26)
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-cast:v13.2.1'

 //是否需要AliPlayer模式
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.2.1'

 //根据你的需求ijk模式的so
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-arm64:v13.2.1'
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-armv7a:v13.2.1'
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-armv5:v13.2.1'
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-x86:v13.2.1'
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-x64:v13.2.1'

C、支持其他格式协议的(mpeg,rtsp, concat、crypto协议,支持 16k Page Size)

A、B普通版本支持263/264/265等,对于mpeg编码会有声音无画面情况。
C 引入的so支持mpeg编码和其他补充协议,但是so包相对变大。

 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-java:v13.2.1'

 //是否需要ExoPlayer模式
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-exo2:v13.2.1'

 //是否需要AliPlayer模式
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.2.1'

 //更多ijk的编码支持
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-ex_so:v13.2.1'

代码中的全局切换支持(更多请参看下方文档和demo)


//EXOPlayer内核,支持格式更多
PlayerFactory.setPlayManager(Exo2PlayerManager.class);
//系统内核模式
PlayerFactory.setPlayManager(SystemPlayerManager.class);
//ijk内核,默认模式
PlayerFactory.setPlayManager(IjkPlayerManager.class);
//aliplay 内核,默认模式
PlayerFactory.setPlayManager(AliPlayerManager.class);

//exo缓存模式,支持m3u8,只支持exo
//需要在 Exo 缓存创建前设置,默认 512 MB
ExoSourceManager.setCacheMaxSize(1024L * 1024L * 1024L);
CacheFactory.setCacheManager(ExoPlayerCacheManager.class);
//代理缓存模式,支持所有模式,不支持m3u8等,默认
CacheFactory.setCacheManager(ProxyCacheManager.class);

//切换渲染模式
GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
//默认显示比例
GSYVideoType.SCREEN_TYPE_DEFAULT = 0;
//16:9
GSYVideoType.SCREEN_TYPE_16_9 = 1;
//4:3
GSYVideoType.SCREEN_TYPE_4_3 = 2;
//全屏裁减显示,为了显示正常 CoverImageView 建议使用FrameLayout作为父布局
GSYVideoType.SCREEN_TYPE_FULL = 4;
//全屏拉伸显示,使用这个属性时,surface_container建议使用FrameLayout
GSYVideoType.SCREEN_MATCH_FULL = -4;
/***
 * SCREEN_TYPE_CUSTOM 下自定义显示比例
 * @param screenScaleRatio  高宽比,如 16:9
 */
public static void setScreenScaleRatio(float screenScaleRatio)

//切换绘制模式
GSYVideoType.setRenderType(GSYVideoType.SUFRACE);
GSYVideoType.setRenderType(GSYVideoType.GLSURFACE);
GSYVideoType.setRenderType(GSYVideoType.TEXTURE);

//ijk关闭log
IjkPlayerManager.setLogLevel(IjkMediaPlayer.IJK_LOG_SILENT);

//exoplayer自定义MediaSource
ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() {
@Override
public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) {
//可自定义MediaSource
return null;
}
});

[--- 更多依赖方式请点击 - ](https://git

...(内容过长,已截断,更多详情请访问项目地址)

⬇️ 下载地址

喜欢就支持一下吧
点赞 0 分享 赞赏
评论 抢沙发
OωO
取消
广告