### Example: Updating Module Configuration for Dual Publish Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DUAL_CHANNEL_PUBLISH.md Example of updating the `build.gradle` for a module (gsyVideoPlayer-base) to support dual publishing. ```gradle // gsyVideoPlayer-base/build.gradle apply from: "$rootDir/gradle/lib.gradle" // GitHub Packages (keep as is) apply from: "$rootDir/gradle/publish.gradle" // Maven Central (new) apply from: "$rootDir/gradle/maven-central-publish.gradle" android { namespace 'com.shuyu.gsy.base' } dependencies { api viewDependencies.ijkplayer } // GitHub Packages repository configuration publishing { repositories { maven { name = "gsyvideoplayer" url = "https://maven.pkg.github.com/CarGuo/GSYVideoPlayer" credentials { username = System.getenv("GITHUB_ACTOR") password = System.getenv("GITHUB_TOKEN") } } } } # After this configuration: # - ./gradlew publish -> com.shuyu:gsyvideoplayer-base:13.0.0 (GitHub) # - ./gradlew publishMavenCentralPublicationToSonatypeRepository -> io.github.carguo:gsyvideoplayer-base:13.0.0 (Maven Central) ``` -------------------------------- ### Wrapper Mode with setUpKey Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/COMPOSE_USE.md Example demonstrating how to use setUpKey to trigger re-execution of setUp when parameters change. ```kotlin GSYVideoPlayerView( setUp = { player -> GSYVideoOptionBuilder().setUrl(url).build(player); player.startPlayLogic() }, setUpKey = url, // url 变化时再次调用 setUp,否则 update 阶段是 no-op ) ``` -------------------------------- ### Cygwin Installation Note Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/BUILD_SO.md A reminder to select 'make' when installing Cygwin. ```bash make ``` -------------------------------- ### SimpleListVideoActivityMode2 Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Example demonstrating the use of SimpleListVideoActivityMode2 with GSYVideoPlayer. ```java gsySmallVideoHelperBuilder.setVideoTitle("title " + position) .setUrl(url); smallVideoHelper.startPlay(); } }); ``` -------------------------------- ### Activity Setup and Lifecycle Configuration Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Java code for setting up the GSYVideoHelper and configuring its lifecycle methods within an Activity. ```Java GSYVideoHelper smallVideoHelper; ListVideoAdapter listVideoAdapter; GSYVideoHelper.GSYVideoHelperBuilder gsySmallVideoHelperBuilder; int lastVisibleItem; int firstVisibleItem; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_video2); //创建小窗口帮助类 smallVideoHelper = new GSYVideoHelper(this); //配置 gsySmallVideoHelperBuilder = new GSYVideoHelper.GSYVideoHelperBuilder(); gsySmallVideoHelperBuilder .setHideStatusBar(true) .setNeedLockFull(true) .setCacheWithPlay(true) .setShowFullAnimation(false) .setRotateViewAuto(false) .setLockLand(true) .setVideoAllCallBack(new GSYSampleCallBack(){ @Override public void onQuitSmallWidget(String url, Object... objects) { super.onQuitSmallWidget(url, objects); //大于0说明有播放,//对应的播放列表TAG if (smallVideoHelper.getPlayPosition() >= 0 && smallVideoHelper.getPlayTAG().equals(ListVideoAdapter.TAG)) { //当前播放的位置 int position = smallVideoHelper.getPlayPosition(); //不可视的是时候 if ((position < firstVisibleItem || position > lastVisibleItem)) { //释放掉视频 smallVideoHelper.releaseVideoPlayer(); listVideoAdapter.notifyDataSetChanged(); } } } }); smallVideoHelper.setGsyVideoOptionBuilder(gsySmallVideoHelperBuilder); videoList.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { ListVideo2Activity.this.firstVisibleItem = firstVisibleItem; lastVisibleItem = firstVisibleItem + visibleItemCount; //大于0说明有播放,//对应的播放列表TAG if (smallVideoHelper.getPlayPosition() >= 0 && smallVideoHelper.getPlayTAG().equals(ListVideoAdapter.TAG)) { //当前播放的位置 int position = smallVideoHelper.getPlayPosition(); //不可视的是时候 if ((position < firstVisibleItem || position > lastVisibleItem)) { //如果是小窗口就不需要处理 if (!smallVideoHelper.isSmall()) { //小窗口 int size = CommonUtil.dip2px(ListVideo2Activity.this, 150); smallVideoHelper.showSmallVideo(new Point(size, size), false, true); } } else { if (smallVideoHelper.isSmall()) { smallVideoHelper.smallVideoToNormal(); } } } } }); } @Override public void onBackPressed() { if (smallVideoHelper.backFromFull()) { return; } super.onBackPressed(); } @Override protected void onDestroy() { super.onDestroy(); smallVideoHelper.releaseVideoPlayer(); GSYVideoManager.releaseAllVideos(); } ``` -------------------------------- ### Install build dependencies Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/BUILD_SO_EN.md Install required system packages for the compilation environment. ```bash sudo apt-get install git sudo apt-get install yasm ``` -------------------------------- ### Dependency Declaration for Maven Central Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DUAL_CHANNEL_PUBLISH.md Example dependency declaration for a project published to Maven Central. ```gradle dependencies { implementation 'io.github.carguo:gsyvideoplayer-java:13.0.0' } ``` -------------------------------- ### WebVTT Thumbnail Preview Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/README_CN.md Example of how to use WebVTT for thumbnail previews in the progress bar, including VTT format and library usage. ```text WEBVTT 00:00:00.000 --> 00:00:01.000 160p-00001.jpg#xywh=0,0,284,160 ``` -------------------------------- ### GSYVideoPlayer Setup and Playback Source: https://github.com/carguo/gsyvideoplayer/wiki/GSYVideoPlayer Methods for initializing the video player with a URL and controlling playback state. ```APIDOC ## setUp ### Description Configures the video player with a source URL and optional caching/header settings. ### Parameters #### Request Body - **url** (String) - Required - The video playback URL. - **cacheWithPlay** (boolean) - Required - Whether to enable side-play-side-cache (set to false for M3U8/HLS). - **cachePath** (File) - Optional - Custom cache directory path. - **mapHeadData** (Map) - Optional - HTTP header information. - **objects** (Object...) - Optional - Additional metadata, where object[0] is typically the title. ### Response - **result** (boolean) - Returns true if setup was successful. ``` -------------------------------- ### Custom UI Example (Empty Control) Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/GSYVIDEO_PLAYER_PROJECT_INFO.md Example of customizing touch gestures for a video player. ```java import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer; public class EmptyControlVideo extends StandardGSYVideoPlayer { @Override protected void touchSurfaceMoveFullLogic(float absDeltaX, float absDeltaY, float y) { // Custom logic for touch move in full screen } @Override protected void touchDoubleUp() { // Custom logic for double tap } // Other methods for customizing UI interactions } ``` -------------------------------- ### Build and Test Command Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/SUBTITLE_CN.md Command to build the project, run unit tests, install the APK, and start the app. ```bash ./gradlew :gsyVideoPlayer-java:testDebugUnitTest :app:assembleDebug adb install -r app/build/outputs/apk/debug/app-debug.apk ``` -------------------------------- ### Dependency Declaration for GitHub Packages Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DUAL_CHANNEL_PUBLISH.md Example dependency declaration for a project published to GitHub Packages. ```gradle dependencies { implementation 'com.shuyu:gsyvideoplayer-java:13.0.0' } ``` -------------------------------- ### setUpLazy Method Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/UPDATE_VERSION.md Sets up the player lazily, performing the actual setup only when playback is initiated. ```java /** * 在点击播放的时候才进行真正setup */ public boolean setUpLazy(String url, boolean cacheWithPlay, File cachePath, Map mapHeadData, String title) ``` -------------------------------- ### Switching Aspect Ratio Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Code examples demonstrating how to switch between different screen display ratios for the video player. ```java //Default display ratio GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_DEFAULT); //16:9 GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_16_9); //Full screen cropped display, for normal display CoverImageView, it is recommended to use FrameLayout as the parent layout GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_FULL); //Full screen stretch display, when using this attribute, surface_container is recommended to use FrameLayout GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL); //4:3 GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_4_3); ``` -------------------------------- ### Regression Checklist: Build and Install Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/KEEP_LAST_FRAME_EN.md Commands to build the debug APK and install it on an Android device. ```bash ./gradlew :app:assembleDebug adb install -r app/build/outputs/apk/debug/app-debug.apk adb shell am start -n com.example.gsyvideoplayer/.MainActivity ``` -------------------------------- ### Set Precise Start Time Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/QUESTION_EN.md Configures a global start position for playback. Ensure this is cleared if not required for subsequent playbacks. ```java VideoOptionModel videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "seek-at-start", startPosition); List list = new ArrayList<>(); list.add(videoOptionModel); GSYVideoManager.instance().setOptionModelList(list); ``` -------------------------------- ### Verifying Publish Tasks Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DUAL_CHANNEL_PUBLISH.md Command to list all publishing tasks to verify configuration. ```powershell # View all publish tasks ./gradlew tasks --group publishing # You will see: # - publishReleasePublicationTo... (GitHub Packages) # - publishMavenCentralPublicationTo... (Maven Central) ``` -------------------------------- ### Switching Aspect Ratio Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE_EN.md Demonstrates how to switch between different aspect ratios for video playback. ```java // Default aspect ratio GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_DEFAULT); // 16:9 GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_16_9); // Fullscreen crop, for normal display, it is recommended to use FrameLayout as the parent layout for CoverImageView GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_FULL); // Fullscreen stretch, when using this attribute, it is recommended to use FrameLayout for surface_container GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL); // 4:3 GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_4_3); ``` -------------------------------- ### Wrapper Mode Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/COMPOSE_USE.md Example of using GSYVideoPlayerView as a wrapper within a Compose screen. ```kotlin @Composable fun MyVideoScreen(url: String) { GSYVideoPlayerView( modifier = Modifier .fillMaxWidth() .aspectRatio(16f / 9f), setUp = { GSYVideoOptionBuilder() .setUrl(url) .setCacheWithPlay(true) .setVideoTitle("Compose Demo") .setIsTouchWiget(true) .build(it) it.startPlayLogic() }, // 默认会自动桥接 onPause/onResume 与离屏 release autoPauseResume = true, autoReleaseOnDispose = true, ) } ``` -------------------------------- ### Switching Renderer Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE_EN.md Shows how to switch between different rendering types for the video player. ```java // Default TextureView GSYVideoType.setRenderType(GSYVideoType.TEXTURE); // SurfaceView, the effect is poor during animation switching, etc. GSYVideoType.setRenderType(GSYVideoType.SUFRACE); // GLSurfaceView, supports filters GSYVideoType.setRenderType(GSYVideoType.GLSURFACE); ``` -------------------------------- ### Module Configuration Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/MAVEN_CENTRAL_AUTOMATION.md Example of how to add Maven Central publishing configuration to a module's build.gradle file, alongside existing GitHub Packages configuration. ```gradle // 保留原有的 GitHub Packages 配置 apply from: "$rootDir/gradle/publish.gradle" // 新增 Maven Central 配置 (不是替换!) apply from: "$rootDir/gradle/maven-central-publish.gradle" // 保留原有的 publishing 配置 publishing { repositories { maven { name = "gsyvideoplayer" url = "https://maven.pkg.github.com/CarGuo/GSYVideoPlayer" credentials { username = System.getenv("GITHUB_ACTOR") password = System.getenv("GITHUB_TOKEN") } } } } ``` -------------------------------- ### Player Configuration in onCreate Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE_EN.md Java code to configure the GSYVideoPlayer with external rotation support and listeners. ```java // External helper for rotation, helps with fullscreen orientationUtils = new OrientationUtils(this, detailPlayer); // Do not enable external rotation initially orientationUtils.setEnable(false); GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder(); gsyVideoOption.setThumbImageView(imageView) .setIsTouchWiget(true) .setRotateViewAuto(false) .setLockLand(false) .setAutoFullWithSize(true) .setShowFullAnimation(false) .setNeedLockFull(true) .setUrl(url) .setCacheWithPlay(false) .setVideoTitle("Test Video") .setVideoAllCallBack(new GSYSampleCallBack() { @Override public void onPrepared(String url, Object... objects) { super.onPrepared(url, objects); // Can only rotate and go fullscreen after playback starts orientationUtils.setEnable(true); isPlay = true; } @Override public void onQuitFullscreen(String url, Object... objects) { super.onQuitFullscreen(url, objects); Debuger.printfError("***** onQuitFullscreen **** " + objects[0]);//title Debuger.printfError("***** onQuitFullscreen **** " + objects[1]);//current non-fullscreen player if (orientationUtils != null) { orientationUtils.backToProtVideo(); } } }).setLockClickListener(new LockClickListener() { @Override public void onClick(View view, boolean lock) { if (orientationUtils != null) { // Cooperate with onConfigurationChanged below orientationUtils.setEnable(!lock); } } }).build(detailPlayer); detailPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Directly go to landscape orientationUtils.resolveByClick(); // The first true is whether to hide the action bar, the second true is whether to hide the status bar detailPlayer.startWindowFullscreen(SimpleDetailActivityMode2.this, true, true); } }); ``` -------------------------------- ### Initialize dependencies Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/BUILD_SO_EN.md Download OpenSSL and FFMPEG source code required for the build. ```bash ./init-android-openssl.sh ./init-android.sh ``` -------------------------------- ### SimpleListVideoActivityMode2 Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE_EN.md This snippet shows how to handle a click event on a player button within a list item to start video playback using GSYVideoPlayer. ```java holder.playerBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { notifyDataSetChanged(); smallVideoHelper.setPlayPositionAndTag(position, TAG); final String url = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"; gsySmallVideoHelperBuilder.setVideoTitle("title " + position) .setUrl(url); smallVideoHelper.startPlay(); } }); ``` -------------------------------- ### Switching Render Type Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Code examples for switching the rendering view type of the video player. ```java //Default TextureView GSYVideoType.setRenderType(GSYVideoType.TEXTURE); //SurfaceView, animation switching, etc. have poor effects GSYVideoType.setRenderType(GSYVideoType.SUFRACE); //GLSurfaceView, supports filters GSYVideoType.setRenderType(GSYVideoType.GLSURFACE); ``` -------------------------------- ### Jitpack Direct Introduction Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DEPENDENCIES_EN.md Direct dependency introduction using Jitpack for the complete GSYVideoPlayer version and the AliPlayer mode. ```groovy //Complete version introduction implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer:v13.0.0' //Whether AliPlayer mode is needed implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.0.0' ``` -------------------------------- ### Adapter Usage Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Example of how to use GSYVideoHelper within an adapter to manage video playback for list items. ```Java smallVideoHelper.addVideoPlayer(position, holder.imageView, TAG, holder.videoContainer, holder.playerBtn); holder.playerBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { notifyDataSetChanged(); smallVideoHelper.setPlayPositionAndTag(position, TAG); final String url = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"; ``` -------------------------------- ### MavenCentral Reference - Direct Introduction Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DEPENDENCIES_EN.md Directly introduce the complete version or the AliPlayer mode of GSYVideoPlayer. ```groovy //Complete version introduction implementation 'io.github.carguo:gsyvideoplayer:13.0.0' //Whether AliPlayer mode is needed implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.0.0' ``` -------------------------------- ### Custom Manager Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/GSYVIDEO_PLAYER_PROJECT_INFO.md Demonstrates how to implement a custom Manager for multiple video cores playing simultaneously. ```java import com.shuyu.gsyvideoplayer.listener.GSYVideoOptionBuilder; import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer; import com.shuyu.gsyvideoplayer.video.base.GSYVideoReducer; public class CustomManager extends GSYVideoReducer { @Override protected void fullScreen(Context context, GSYBaseVideoPlayer gsyBaseVideoPlayer) { // Implementation for full screen } @Override protected void normalScreen(Context context, GSYBaseVideoPlayer gsyBaseVideoPlayer) { // Implementation for normal screen } // Other methods as needed for custom manager functionality } ``` -------------------------------- ### Configure IJKPlayer modules Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/BUILD_SO_EN.md Select the desired codec configuration by linking the appropriate module file. ```bash cd config rm module.sh ln -s module-default.sh module.sh ``` ```bash cd config rm module.sh ln -s module-lite-hevc.sh module.sh ``` ```bash cd config rm module.sh ln -s module-lite.sh module.sh ``` -------------------------------- ### Player Configuration in onCreate Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Configure the player in onCreate, enabling rotation support and adding listeners. This example uses GSYVideoOptionBuilder. ```java //外部辅助的旋转,帮助全屏 orientationUtils = new OrientationUtils(this, detailPlayer); //初始化不打开外部的旋转 orientationUtils.setEnable(false); GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder(); gsyVideoOption.setThumbImageView(imageView) .setIsTouchWiget(true) .setRotateViewAuto(false) .setLockLand(false) .setAutoFullWithSize(true) .setShowFullAnimation(false) .setNeedLockFull(true) .setUrl(url) .setCacheWithPlay(false) .setVideoTitle("测试视频") .setVideoAllCallBack(new GSYSampleCallBack() { @Override public void onPrepared(String url, Object... objects) { super.onPrepared(url, objects); //开始播放了才能旋转和全屏 orientationUtils.setEnable(true); isPlay = true; } @Override public void onQuitFullscreen(String url, Object... objects) { super.onQuitFullscreen(url, objects); Debuger.printfError("***** onQuitFullscreen **** " + objects[0]);//title Debuger.printfError("***** onQuitFullscreen **** " + objects[1]);//当前非全屏player if (orientationUtils != null) { orientationUtils.backToProtVideo(); } } }).setLockClickListener(new LockClickListener() { @Override public void onClick(View view, boolean lock) { if (orientationUtils != null) { //配合下方的onConfigurationChanged orientationUtils.setEnable(!lock); } } }).build(detailPlayer); detailPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //直接横屏 orientationUtils.resolveByClick(); //第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar detailPlayer.startWindowFullscreen(SimpleDetailActivityMode2.this, true, true); } }); ``` -------------------------------- ### act Debugging Tips Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/MAVEN_CENTRAL_PUBLISH.md Tips for debugging GitHub Actions locally using 'act'. ```bash # Verbose logs act -v # Interactive shell (when workflow fails) act workflow_dispatch --container-architecture linux/amd64 -s GITHUB_TOKEN=fake # Reuse Docker container (speeds up debugging) act --reuse ``` -------------------------------- ### Basic Playback in Compose (Wrapper) Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/COMPOSE_USE.md Example of basic video playback using the GSYVideoPlayerView (Wrapper mode) in Jetpack Compose, mirroring Java/XML demo setup. ```kotlin GSYVideoPlayerView( modifier = Modifier.fillMaxWidth().aspectRatio(16f / 9f), setUp = { player -> GSYVideoOptionBuilder() .setUrl(url) .setVideoTitle(title) .setIsTouchWiget(true) .build(player) }, ) ``` -------------------------------- ### Step-by-Step Verification Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/MAVEN_CENTRAL_PUBLISH.md Commands to test different aspects of the publishing process locally without running the full workflow. ```bash # 1. Test build ./gradlew clean build # 2. Test publish to local (no credentials needed) ./gradlew publishToMavenLocal # 3. Test signing (requires GPG setup) $env:GPG_PASSPHRASE = "your-passphrase" ./gradlew signReleasePublication # 4. View what will be published ./gradlew publishToMavenLocal --dry-run # 5. View all publishing tasks ./gradlew tasks --group publishing ``` -------------------------------- ### Handling different cache paths in a list Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/UPDATE_VERSION_EN.md Illustrates the setup for scenarios where cache paths differ within a list, including UI initialization logic and click listeners for starting playback. ```java //If the cache paths in a list are different, you need to use the following method //To avoid being unavailable when returning from full screen, only initialize the UI that is not at the current position if (playPosition < 0 || playPosition != position || !GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)) { holder.gsyVideoPlayer.initUIState(); } //If you set that you can play by clicking the cover, if the cache list path is inconsistent, you also need to set the cover click holder.gsyVideoPlayer.setThumbPlay(true); holder.gsyVideoPlayer.getStartButton().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Need to switch the cache path holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), "")); holder.gsyVideoPlayer.startPlayLogic(); } }); holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Need to switch the cache path holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), "")); holder.gsyVideoPlayer.startPlayLogic(); } }); ``` -------------------------------- ### Jitpack Introduction with Java and Desired SO Support Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DEPENDENCIES_EN.md Introduction of GSYVideoPlayer-java along with specific SO support for different architectures (arm64, armv7a, armv5, x86, x64) and optional ExoPlayer and AliPlayer modes. ```groovy implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-java:v13.0.0' //Whether ExoPlayer mode is needed implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-exo2:v13.0.0' //Whether AliPlayer mode is needed implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-aliplay:v13.0.0' //so of ijk mode according to your needs implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-arm64:v13.0.0' implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-armv7a:v13.0.0' implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-armv5:v13.0.0' implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-x86:v13.0.0' implementation 'com.github.CarGuo.GSYVideoPlayer:gsyvideoplayer-x64:v13.0.0' ``` -------------------------------- ### WebVTT Seek Preview Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/RECENT_FEATURES_EN.md Example of a WebVTT thumbnail track format. ```text WEBVTT 00:00:00.000 --> 00:00:05.000 thumbs.jpg#xywh=0,0,160,90 ``` -------------------------------- ### Detail Player Configuration Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE_EN.md Java code demonstrating the onCreate method and configuration overrides for a detail player activity. ```java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail_player); detailPlayer = (StandardGSYVideoPlayer) findViewById(R.id.detail_player); // Add title detailPlayer.getTitleTextView().setVisibility(View.GONE); detailPlayer.getBackButton().setVisibility(View.GONE); initVideoBuilderMode(); } @Override public StandardGSYVideoPlayer getGSYVideoPlayer() { return detailPlayer; } @Override public GSYVideoOptionBuilder getGSYVideoOptionBuilder() { // For a built-in cover, refer to SampleCoverVideo ImageView imageView = new ImageView(this); loadCover(imageView, url); return new GSYVideoOptionBuilder() .setThumbImageView(imageView) .setUrl(url) .setCacheWithPlay(true) .setVideoTitle(" ") .setIsTouchWiget(true) .setRotateViewAuto(false) .setLockLand(false) .setShowFullAnimation(false) .setNeedLockFull(true) .setSeekRatio(1); } @Override public void clickForFullScreen() { } /** * Whether to enable auto-rotation to landscape, true means enabled */ @Override public boolean getDetailOrientationRotateAuto() { return true; } ``` -------------------------------- ### Get Full Window Player Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/UPDATE_VERSION_EN.md Get the full-screen player object. ```Java /** * Get the full-screen player object * * @return GSYVideoPlayer returns null if there is none. */ public GSYVideoPlayer getFullWindowPlayer() ``` -------------------------------- ### Github Package Dependency Method - Direct Introduction Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DEPENDENCIES_EN.md Directly introduce the complete version or the AliPlayer mode of GSYVideoPlayer using the Github Package repository. ```groovy //Complete version introduction implementation 'com.shuyu:gsyvideoplayer:13.0.0' //Whether AliPlayer mode is needed implementation 'com.shuyu:gsyvideoplayer-aliplay:13.0.0' ``` -------------------------------- ### Player Factory Initialization (Commented) Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/UPDATE_VERSION.md Commented out examples showing how to set the player manager using instances. ```java //PlayerFactory.setPlayManager(new Exo2PlayerManager());//EXO模式 //PlayerFactory.setPlayManager(new SystemPlayerManager());//系统模式 //PlayerFactory.setPlayManager(new IjkPlayerManager());//ijk模式 ``` -------------------------------- ### Synchronize State During Full-Screen Transitions Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/QUESTION_EN.md Overload startWindowFullscreen and resolveNormalVideoShow to maintain custom player state when switching between full-screen and normal modes. ```java /** * When in full screen, assign the corresponding processing parameter logic to the full screen player * * @param context * @param actionBar * @param statusBar * @return */ @Override public GSYBaseVideoPlayer startWindowFullscreen(Context context, boolean actionBar, boolean statusBar) { SmartPickVideo sampleVideo = (SmartPickVideo) super.startWindowFullscreen(context, actionBar, statusBar); sampleVideo.mSourcePosition = mSourcePosition; sampleVideo.mType = mType; sampleVideo.mUrlList = mUrlList; sampleVideo.mTypeText = mTypeText; sampleVideo.mSwitchSize.setText(mTypeText); return sampleVideo; } /** * When exiting full screen, return the corresponding processing parameter logic to the non-player * * @param oldF * @param vp * @param gsyVideoPlayer */ @Override protected void resolveNormalVideoShow(View oldF, ViewGroup vp, GSYVideoPlayer gsyVideoPlayer) { super.resolveNormalVideoShow(oldF, vp, gsyVideoPlayer); if (gsyVideoPlayer != null) { SmartPickVideo sampleVideo = (SmartPickVideo) gsyVideoPlayer; mSourcePosition = sampleVideo.mSourcePosition; mType = sampleVideo.mType; mTypeText = sampleVideo.mTypeText; mSwitchSize.setText(mTypeText); setUp(mUrlList, mCache, mCachePath, mTitle); } } ``` -------------------------------- ### Install YASM on macOS Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/BUILD_SO_EN.md Install the required yasm dependency via Homebrew if the build fails due to missing or outdated versions. ```bash brew install yasm ``` -------------------------------- ### Normal mode setup with custom cache path Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/UPDATE_VERSION.md Demonstrates setting up video playback with a custom cache path, including handling list scenarios where cache paths might differ. ```java //默认缓存路径方式 holder.gsyVideoPlayer.setUp(url, true , ""); ··· //一个列表的视频缓存路径相同 holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), "")); ··· //如果一个列表里的缓存路径不同,需要用下方的方式 //避免全屏返回的时候不可用了,只初始化不是当前位置的ui if (playPosition < 0 || playPosition != position || !GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)) { holder.gsyVideoPlayer.initUIState(); } //如果设置了点击封面可以播放,如果缓存列表路径不一致,还需要设置封面点击 holder.gsyVideoPlayer.setThumbPlay(true); holder.gsyVideoPlayer.getStartButton().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //需要切换缓存路径的 holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), "")); holder.gsyVideoPlayer.startPlayLogic(); } }); holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //需要切换缓存路径的 holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), "")); holder.gsyVideoPlayer.startPlayLogic(); } }); ``` -------------------------------- ### Set Seek Position on Start Source: https://github.com/carguo/gsyvideoplayer/wiki/GSYVideoPlayer Specify the starting position for playback. This can help address issues with video jumping in the first few seconds. ```java /** * Start playback from a specific position * Currently addresses issues with jumping in the first few seconds */ public void setSeekOnStart(long seekOnStart) ``` -------------------------------- ### Lazy Setup Source: https://github.com/carguo/gsyvideoplayer/wiki/基础Player-API Method to set up the player lazily, meaning the actual setup occurs only when playback is initiated. ```Java /** * 在点击播放的时候才进行真正setup */ public boolean setUpLazy(String url, boolean cacheWithPlay, File cachePath, Map mapHeadData, String title) ``` -------------------------------- ### Enable WAV Support Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DECODERS_EN.md Configuration options for WAV audio format, including PCM encoding and decoding. ```bash --enable-libwavpack --enable-muxer=wav --enable-demuxer=wav --enable-decoder=wavpack --enable-encoder=wavpack --enable-decoder=wav --enable-encoder=wav --enable-encoder=pcm_s16le --enable-decoder=pcm_s16le --enable-encoder=pcm_u8 --enable-decoder=pcm_u8 --enable-muxer=pcm_u8 --enable-demuxer=pcm_u8 ``` -------------------------------- ### WebVTT Thumbnail Track Example Source: https://github.com/carguo/gsyvideoplayer/blob/master/README.md Example of a WebVTT thumbnail track format used for seek preview, specifying image coordinates. ```text WEBVTT 00:00:00.000 --> 00:00:00.000 160p-00001.jpg#xywh=0,0,284,160 ``` -------------------------------- ### Adapter Usage for List Video Helper Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE_EN.md Example of how to integrate the GSYVideoHelper into a RecyclerView or ListView adapter to manage video playback for each item. ```java smallVideoHelper.addVideoPlayer(position, holder.imageView, TAG, holder.videoContainer, holder.playerBtn); ``` -------------------------------- ### MavenCentral Reference - Add Java and SO Support Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/DEPENDENCIES_EN.md Add Java support and specific SO libraries for different architectures (arm64, armv7a, armv5, x86, x64) and optional ExoPlayer or AliPlayer modes. ```groovy implementation 'io.github.carguo:gsyvideoplayer-java:13.0.0' //Whether ExoPlayer mode is needed implementation 'io.github.carguo:gsyvideoplayer-exo2:13.0.0' //Whether AliPlayer mode is needed implementation 'io.github.carguo:gsyvideoplayer-aliplay:13.0.0' //so of ijk mode according to your needs implementation 'io.github.carguo:gsyvideoplayer-arm64:13.0.0' implementation 'io.github.carguo:gsyvideoplayer-armv7a:13.0.0' implementation 'io.github.carguo:gsyvideoplayer-armv5:13.0.0' implementation 'io.github.carguo:gsyvideoplayer-x86:13.0.0' implementation 'io.github.carguo:gsyvideoplayer-x64:13.0.0' ``` -------------------------------- ### Seek on Start Source: https://github.com/carguo/gsyvideoplayer/wiki/基础Player-API Method to set the starting position for playback in milliseconds. This is useful for addressing potential stuttering issues in the first few seconds. It should be called before `startPlayLogic`. ```Java public long getSeekOnStart() /** * 从哪里开始播放 * 目前有时候前几秒有跳动问题,毫秒 * 需要在startPlayLogic之前,即播放开始之前 */ public void setSeekOnStart(long seekOnStart) ``` -------------------------------- ### Checkout IJKPlayer source Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/BUILD_SO_EN.md Switch to a specific release tag for the IJKPlayer source code. ```bash git checkout -B k0.7.5 // Refer to ijk's dependency library version for this version number ``` -------------------------------- ### Cache Factory Initialization (Commented) Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/UPDATE_VERSION.md Commented out examples showing how to set the cache manager using instances. ```java //CacheFactory.setCacheManager(new ExoPlayerCacheManager());//exo缓存模式,支持m3u8,只支持exo //CacheFactory.setCacheManager(new ProxyCacheManager());//代理缓存模式,支持所有模式,不支持m3u8等 ``` -------------------------------- ### Activity Not Exported Error Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/JAVA_TEST_PLAYBOOK.md Example of an error when an Activity is not exported and how to fix it. ```bash am start -n com.example.gsyvideoplayer/.DetailPlayer ``` -------------------------------- ### Get Buffer Progress Source: https://github.com/carguo/gsyvideoplayer/wiki/GSYVideoPlayer Retrieve the current buffering or caching progress percentage. ```java /** * Buffering progress / Cache progress */ public int getBuffterPoint() { return mBuffterPoint; } ``` -------------------------------- ### Callback Example in Compose (Wrapper) Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/COMPOSE_USE.md Demonstrates how to use Java-style callbacks within the Wrapper mode in Compose. ```kotlin .setVideoAllCallBack(object : GSYSampleCallBack() { override fun onPrepared(url: String?, vararg objects: Any?) { super.onPrepared(url, *objects) // ... 上报埋点 / 更新 UI state } }) ``` -------------------------------- ### Get Current Playback State Source: https://github.com/carguo/gsyvideoplayer/wiki/GSYVideoPlayer Retrieve the current playback state of the video player. ```java /** * Get current playback state */ public int getCurrentState() { return mCurrentState; } ``` -------------------------------- ### List and Fullscreen Configuration Source: https://github.com/carguo/gsyvideoplayer/wiki/GSYVideoPlayer Methods for handling video playback in lists and managing fullscreen transitions. ```APIDOC ## List and Fullscreen ### Description Configuration methods to prevent playback displacement in lists and handle fullscreen exit. ### Methods - **setPlayTag(String playTag)**: Sets a unique tag to prevent displacement in lists. - **setPlayPosition(int playPosition)**: Sets the position index to prevent displacement in lists. - **backFromWindowFull(Context context)**: Exits fullscreen mode (static method). ``` -------------------------------- ### Direct Introduction (Github Packages) Source: https://github.com/carguo/gsyvideoplayer/blob/master/README.md Direct dependency declaration for the complete GSYVideoPlayer version using Github Packages. ```groovy //Complete version introduction implementation 'com.shuyu:gsyvideoplayer:13.0.0' //Whether AliPlayer mode is needed implementation 'com.shuyu:gsyvideoplayer-aliplay:13.0.0' ``` -------------------------------- ### ExoMediaSourceInterceptListener Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Implement ExoMediaSourceInterceptListener for custom MediaSource in Exo mode. ```java ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() { /** * @param dataSource 链接 * @param preview 是否带上header,默认有header自动设置为true * @param cacheEnable 是否需要缓存 * @param isLooping 是否循环 * @param cacheDir 自定义缓存目录 * @return 返回不为空时,使用返回的自定义mediaSource */ @Override public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) { return null; } }); ``` -------------------------------- ### Customizing CacheFactory Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/USE.md Customize the cache manager using CacheFactory.setCacheManager(). ```java //CacheFactory.setCacheManager(new ExoPlayerCacheManager());//exo缓存模式,支持m3u8,只支持exo //CacheFactory.setCacheManager(new ProxyCacheManager());//代理缓存模式,支持所有模式,不支持m3u8等 ``` -------------------------------- ### Send Public Key to Key Servers Source: https://github.com/carguo/gsyvideoplayer/blob/master/doc/MAVEN_CENTRAL_PUBLISH.md Commands to upload your GPG public key to public key servers. ```bash gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_ID gpg --keyserver keys.openpgp.org --send-keys YOUR_KEY_ID ```