GSYVideoPlayer README

The project's README from github.com/CarGuo/GSYVideoPlayer. As one markdown file: README.md.

中文文档

Supports IJKPlayer, Media3(EXOPlayer2), MediaPlayer, AliPlayer, implementing a multi-functional video player. (Please read the following instructions carefully, most questions can be answered below).

* HarmonyOS version openharmony-tpc/GSYVideoPlayer

If cloning is too slow or images are not visible, you can try to synchronize from the following addresses

Type Function
Cache Play while caching, using AndroidVideoCache; Media3(ExoPlayer) uses SimpleCache.
Protocols h263\4\5, Https, concat, rtsp, hls, rtmp, crypto, mpeg, etc. (ijk mode format support)
Filters Simple filters (mosaic, black and white, color filter, Gaussian, blur, etc. more than 20 kinds), animation, (watermark, multi-screen playback, etc.).
Frame images Video first frame, video frame screenshots, composed player screenshots including UI, and video to gif function.
Playback List playback, continuous list playback, gravity rotation and manual rotation, video's own rotation attribute, fast and slow playback, network video loading speed.
Screen Adjust display ratio: default, 16:9, 4:3, fill; rotate screen angle during playback (0,90,180,270); mirror rotation.
Kernel IJKPlayer, Media3(EXOPlayer), MediaPlayer, AliPlayer switching, custom kernel
Layout Full screen and non-full screen two sets of layout switching, pure playback support without any operation controls, barrage function, inherited custom any layout.
Playback Singleton playback, multiple simultaneous playback, video list sliding automatic playback, seamless playback of list switching detail pages.
Window Small window, small window playback in multiple windows (including desktop).
Ads Opening ads, skip ad support, interstitial ad function.
Subtitles Unified external subtitle overlay supports SRT/WebVTT across IJK, Media3(EXOPlayer), and MediaPlayer; Media3 embedded cues can bridge to the same UI.
Dash Media3(exo2) mode supports dash; the demo supports HLS master / DASH MPD adaptive quality track switching.
Stream Supports metadata playback
Adapt 16k ex_so adapts to 16K Page Size
openssl Currently ex_so's arm64/x86_64 uses openssl 1.1.1w
FFmpeg Currently ex_so's arm64/x86_64 uses FFmpeg 4.3
FFmpeg Currently ex_so's arm64/x86_64 supports G711a(pcm_alaw)
Cast Optional gsyvideoplayer-cast DLNA/UPnP module built on jUPnP 3.0.3; the core keeps only the protocol-neutral CastCapability / CastProvider / CastSession SPI and does not pull Jetty. Details.
More No black screen when pausing front and back switching; multi-URL quality switching; Exo HLS/DASH adaptive quality; seamless switching support; keep-last-frame demo; WebVTT progress bar preview.
Customization Customizable rendering layer, custom management layer, custom playback layer (control layer), custom cache layer.

Maven Central Version Build Status Github Actions

GitHub stars GitHub forks GitHub issues GitHub License

Star

Official Account Juejin Zhihu CSDN Jianshu
GSYTech Click me Click me Click me Click me

--------------Demo APK Download Address---------------

I. Using Dependencies

There are currently three hosting methods:

--- Version Update Instructions --- .

--- Recent Playback Features --- .

Since jitpack keeps losing packages, it has been migrated to MavenCentral. The usage is as follows:

First Add

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

You can choose one of the following three and add it to the build.gradle under the module.

A. Direct Introduction

 //Complete version introduction

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


//Whether AliPlayer mode is needed
implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.2.1'

//Whether DLNA/UPnP casting is needed (optional, minSdk 26)
implementation 'io.github.carguo:gsyvideoplayer-cast:13.2.1'

B. Add java and the so support you want:

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

 //Whether ExoPlayer mode is needed
 implementation 'io.github.carguo:gsyvideoplayer-exo2:13.2.1'

 //Optional direct RTMP module; exo2 already exposes it transitively
 implementation 'io.github.carguo:gsyvideoplayer-rtmp:13.2.1'

 //Optional DLNA/UPnP cast implementation (minSdk 26); the default player does not include Jetty
 implementation 'io.github.carguo:gsyvideoplayer-cast:13.2.1'

 //Whether AliPlayer mode is needed
 implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.2.1'

 //so of ijk mode according to your needs
 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. Support other format protocols (mpeg, rtsp, concat, crypto protocols, support 16k Page Size)

A and B normal versions support 263/264/265, etc. For mpeg encoding, there will be sound but no picture. The so introduced by C supports mpeg encoding and other supplementary protocols, but the so package is relatively larger.

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

 //Whether ExoPlayer mode is needed
 implementation 'io.github.carguo:gsyvideoplayer-exo2:13.2.1'

 //Whether AliPlayer mode is needed
 implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.2.1'

 //More ijk encoding support
 implementation 'io.github.carguo:gsyvideoplayer-ex_so:13.2.1'

D. Jetpack Compose Support (Optional)

The gsyvideoplayer-compose module is published with v13.1.0. It can be consumed from Maven Central / GitHub Packages like the other modules, or by depending on the source module directly with implementation project(":gsyVideoPlayer-compose") when working inside this repository.

🛠 Toolchain note: the Compose module is verified on JDK 21 in CI (.github/workflows/*.yml — actions/setup-java java-version: 21) and JDK 17 locally (the module pins sourceCompatibility / targetCompatibility / jvmTarget = 17 in gsyVideoPlayer-compose/build.gradle). Both are fine; just make sure your local JDK is ≥ 17 so Kotlin 2.0.21 + AGP 8.6.1 can build.

The new gsyvideoplayer-compose module exposes Compose entries on top of the existing kernels and UI without touching any legacy code:

// Maven Central:
implementation 'io.github.carguo:gsyvideoplayer-compose:13.2.1'

// Source dependency for local development:
implementation project(':gsyVideoPlayer-compose')
// compose-bom is api-exposed from the module; consumers still manage androidx.compose.* per their own project setup.

See doc/COMPOSE_USE.md. The sample app provides a Compose Demo entry with 24 runnable Compose Activities — covering Wrapper basics, Native detail/list/multi-window/auto-play/seamless-switch, plus P5 differentiating capabilities (filter, cache/download, ad pre-roll, subtitle, custom danmaku, EXO multi-source, parallel multi-window) and P5-2 modern app patterns (vertical short video, floating window, multi-type list, web mixed layout, audio-only, URL/local file, MediaCodec hardware switch, themed custom controls). DemoSamples.kt is a shared data object of test URLs, not a runnable Activity. Outstanding gaps and the rolling roadmap are tracked in doc/COMPOSE_BACKLOG.md.

Since Jitpack often has the problem of random loss of historical packages, a new Github Package dependency method is added. The usage is as follows:

However, accessing github package requires a token to access, which is more troublesome, but it is stable.

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()

    }
}

In theory, it is the avatar in the upper right corner - Settings - Developer Settings - Personal access tokens - tokens (classic) - Generate new token (classic) - read:packages Remember to choose permanent for the expiration time

Tip: this repository's root build.gradle already supports reading the GitHub Packages credentials from a Gradle property or environment variable, so you don't have to hard-code your own token in the source tree:

# ~/.gradle/gradle.properties (recommended for local builds)
githubReadUser=<your-github-name>
githubReadToken=<your-classic-token-with-read:packages>

Or in CI:

export GITHUB_READ_USER=<your-github-name>
export GITHUB_READ_TOKEN=<your-classic-token-with-read:packages>

The hard-coded carsmallguo / ghp_... pair is only kept as a fallback so first-time clones still build out of the box; it may be revoked at any time, so prefer providing your own.

You can choose one of the following three and add it to the build.gradle under the module.

A. Direct Introduction

 //Complete version introduction
 implementation 'com.shuyu:gsyvideoplayer:13.2.1'


 //Whether AliPlayer mode is needed
 implementation 'com.shuyu:gsyvideoplayer-aliplay:13.2.1'

 //Whether DLNA/UPnP casting is needed (optional, minSdk 26)
 implementation 'com.shuyu:gsyvideoplayer-cast:13.2.1'

B. Add java and the so support you want:

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

 //Whether ExoPlayer mode is needed
 implementation 'com.shuyu:gsyvideoplayer-exo2:13.2.1'

 //Optional direct RTMP module; exo2 already exposes it transitively
 implementation 'com.shuyu:gsyvideoplayer-rtmp:13.2.1'

 //Optional DLNA/UPnP cast implementation (minSdk 26); the default player does not include Jetty
 implementation 'com.shuyu:gsyvideoplayer-cast:13.2.1'

 //Whether AliPlayer mode is needed
 implementation 'com.shuyu:gsyvideoplayer-aliplay:13.2.1'

 //so of ijk mode according to your needs
 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. Support other format protocols (mpeg, rtsp, concat, crypto protocols, support 16k Page Size)

A and B normal versions support 263/264/265, etc. For mpeg encoding, there will be sound but no picture. The so introduced by C supports mpeg encoding and other supplementary protocols, but the so package is relatively larger.

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

 //Whether ExoPlayer mode is needed
 implementation 'com.shuyu:gsyvideoplayer-exo2:13.2.1'


 //Whether AliPlayer mode is needed
 implementation 'com.shuyu:gsyvideoplayer-aliplay:13.2.1'

 //More ijk encoding support
 implementation 'com.shuyu:gsyvideoplayer-ex_so:13.2.1'

D. Jetpack Compose Support (Optional)

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

3. Jitpack Introduction Method (will continue to be released, but not highly recommended)

Historical packages may have random packet loss, and it is not easy to supplement, see #4144:

First, add in the build.gradle under the project

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

You can choose one of the following three and add it to the build.gradle under the module.

A. Direct Introduction

 //Complete version introduction

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


 //Whether AliPlayer mode is needed
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.2.1'

 //Whether DLNA/UPnP casting is needed (optional, minSdk 26)
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-cast:v13.2.1'

B. Add java and the so support you want:

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

 //Whether ExoPlayer mode is needed
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-exo2:v13.2.1'

 //Optional DLNA/UPnP cast implementation (minSdk 26)
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-cast:v13.2.1'

 //Whether AliPlayer mode is needed
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.2.1'

 //so of ijk mode according to your needs
 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. Support other format protocols (mpeg, rtsp, concat, crypto protocols, support 16k Page Size)

A and B normal versions support 263/264/265, etc. For mpeg encoding, there will be sound but no picture. The so introduced by C supports mpeg encoding and other supplementary protocols, but the so package is relatively larger.

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

 //Whether ExoPlayer mode is needed
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-exo2:v13.2.1'

 //Whether AliPlayer mode is needed
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.2.1'

 //More ijk encoding support
 implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-ex_so:v13.2.1'

Global switching support in code (for more, please refer to the documentation and demo below)


//EXOPlayer kernel, supports more formats
PlayerFactory.setPlayManager(Exo2PlayerManager.class);
//System kernel mode
PlayerFactory.setPlayManager(SystemPlayerManager.class);
//ijk kernel, default mode
PlayerFactory.setPlayManager(IjkPlayerManager.class);
//aliplay kernel, default mode
PlayerFactory.setPlayManager(AliPlayerManager.class);


//exo cache mode, supports m3u8, only supports exo
//Set before Exo cache is created. Default is 512 MB.
ExoSourceManager.setCacheMaxSize(1024L * 1024L * 1024L);
CacheFactory.setCacheManager(ExoPlayerCacheManager.class);
//Proxy cache mode, supports all modes, does not support m3u8, etc., default
CacheFactory.setCacheManager(ProxyCacheManager.class);



//Switch rendering mode
GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
//Default display ratio
GSYVideoType.SCREEN_TYPE_DEFAULT = 0;
//16:9
GSYVideoType.SCREEN_TYPE_16_9 = 1;
//4:3
GSYVideoType.SCREEN_TYPE_4_3 = 2;
//Full screen cropping display, for normal display CoverImageView it is recommended to use FrameLayout as the parent layout
GSYVideoType.SCREEN_TYPE_FULL = 4;
//Full screen stretching display, when using this attribute, it is recommended to use FrameLayout for surface_container
GSYVideoType.SCREEN_MATCH_FULL = -4;
/***
 * 

GSYVideoPlayer (CarGuo/GSYVideoPlayer)

Searching Database…

这是什么?GSYVideoPlayer 是一个开源的 Android 视频播放器库,它把多种播放内核——IJKPlayer、Media3(ExoPlayer2)、MediaPlayer 和 AliPlayer——封装在一个统一的 API 后面,并内置了缓存、弹幕、字幕、滤镜和广告支持。
这是一个独立的播放器应用,还是我添加到自己 Android 项目里的库?它是一个库,不是给最终用户用的应用:你把它作为 Gradle 依赖添加进来,把它的播放器视图和控件嵌入到你自己的布局中。如果你只是想先试试效果,也有一个演示 APK 可以用。
怎么把它添加到我的应用里?在你的模块的 build.gradle 里把它作为 Gradle 依赖添加,自 v11.0.0 起托管在 MavenCentral 上(推荐方式)。GitHub Packages 也可以用,但需要一个 read:packages 令牌;Jitpack 上也还在发布,但会随机丢包。
它用哪些播放引擎——我需要自己安装 ExoPlayer 或 FFmpeg 吗?不需要。内核已经打包好了,可以在代码里通过 PlayerFactory.setPlayManager(...) 切换:IJKPlayer(默认)、Media3/ExoPlayer2、系统自带的 MediaPlayer 和 AliPlayer。IJK 模式基于 FFmpeg,额外支持 rtmp、rtsp 和 hls 等格式。
选依赖变体时有什么要注意的坑吗?有。默认变体(A/B)可以播放 h263/264/265,但 mpeg 视频只有声音没有画面——变体 C 额外支持 mpeg、rtsp、concat、crypto 和 16K 页大小,代价是 .so 文件更大。可选的 Compose 模块还需要 JDK 17 或更高版本。
它只支持 Android 吗?是的,它是一个 Android 库。另外在 openharmony-tpc/GSYVideoPlayer 仓库下有一个独立的 HarmonyOS 移植版。
支持边播边缓存吗?支持。代理缓存(AndroidVideoCache)对所有内核都有效,但不支持 m3u8;在 Media3/ExoPlayer 模式下则改用 SimpleCache,它支持 m3u8,默认 512 MB 缓存,可以通过 ExoSourceManager.setCacheMaxSize 调大。
哪些播放功能是开箱即用的?列表播放并滑动时自动播放、多个视频同时播放、小窗悬浮播放、片前和片中广告(可跳过)、20 多种滤镜、水印、截图帧和视频转 GIF、倍速播放、旋转、多地址清晰度切换、HLS/DASH 自适应码流,以及从列表到详情页的无缝续播。
字幕和弹幕是怎么处理的?统一的外挂字幕浮层在 IJK、Media3 和 MediaPlayer 下都支持 SRT 和 WebVTT,Media3 的内嵌字幕也会接入同一套界面。弹幕内置为一种可以继承和自定义的 barrage 布局。
播放器的外观和行为可以自定义吗?可以——提供全屏和非全屏两套布局,还有不带任何控件的纯播放模式,渲染、管理、控件和缓存这几层都可以替换。可选的 gsyvideoplayer-cast 模块还增加了 DLNA/UPnP 投屏功能。
Creator
CarGuo
Size
510.5 MB
Stars
21.5K
Age
9y
Commits · 90 Days