### Initialize Download Manager Source: https://github.com/706412584/orangeplayer/blob/main/orange-downloader/README.md Example code to initialize and start a download task. ```java SimpleDownloadManager manager = SimpleDownloadManager.getInstance(context); manager.startDownload(url, title); ``` -------------------------------- ### RuntimeException Error Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_CRASH_DIAGNOSIS.md Example of a RuntimeException during activity startup. ```text java.lang.RuntimeException: Unable to start activity ComponentInfo{...} ``` -------------------------------- ### ExoPlayer Usage Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/PLAYER_ENGINES.md Switch to the ExoPlayer engine and initialize video playback. ```java // 切换到 ExoPlayer mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_EXO); // 设置视频 mVideoView.setUp("https://example.com/video.mp4", true, "示例视频"); mVideoView.startPlayLogic(); ``` -------------------------------- ### Build and Install via Command Line Source: https://github.com/706412584/orangeplayer/blob/main/app-tv/README.md Use these Gradle commands to compile the debug version of the app and install it on a connected device. ```bash # 编译 Debug 版本 ./gradlew :app-tv:assembleDebug # 安装到设备 ./gradlew :app-tv:installDebug # 或者直接运行 adb install app-tv/build/outputs/apk/debug/app-tv-debug.apk ``` -------------------------------- ### OrangevideoView setUp 方法示例 Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md 展示了基础用法以及带请求头的视频设置方式。 ```java // 基础用法 videoView.setUp("https://example.com/video.mp4", true, "示例视频"); // 带请求头 Map headers = new HashMap<>(); headers.put("User-Agent", "MyPlayer/1.0"); headers.put("Referer", "https://example.com"); videoView.setUp(url, true, null, headers, "示例视频"); ``` -------------------------------- ### Configure local credentials Source: https://github.com/706412584/orangeplayer/blob/main/docs/MAVEN_CENTRAL_SETUP.md Copy the example properties file and edit it to include your credentials. ```bash # 复制示例文件 cp gradle.properties.example gradle.properties # 编辑并填入真实值 notepad gradle.properties # Windows # vim gradle.properties # Linux/Mac ``` -------------------------------- ### OrangevideoView setUp 方法定义 Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md 定义了用于设置视频地址和播放参数的多种重载方法。 ```java // 基础设置 boolean setUp(String url, boolean cacheWithPlay, String title) // 带缓存路径 boolean setUp(String url, boolean cacheWithPlay, File cachePath, String title) // 带请求头 boolean setUp(String url, boolean cacheWithPlay, File cachePath, Map headers, String title) ``` -------------------------------- ### setVideoList() usage example Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Demonstrates creating a playlist and setting it to the controller. ```java ArrayList> playlist = new ArrayList<>(); HashMap video1 = new HashMap<>(); video1.put("name", "第1集"); video1.put("url", "https://example.com/video1.mp4"); playlist.add(video1); HashMap video2 = new HashMap<>(); video2.put("name", "第2集"); video2.put("url", "https://example.com/video2.mp4"); // 可选:添加请求头 HashMap headers = new HashMap<>(); headers.put("Referer", "https://example.com"); video2.put("headers", headers); playlist.add(video2); controller.setVideoList(playlist); // 第一个视频会自动设置到播放器 videoView.startPlayLogic(); ``` -------------------------------- ### Aliyun Player Usage Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/PLAYER_ENGINES.md Switch to the Aliyun player engine and initialize video playback. ```java // 切换到阿里云播放器 mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_ALI); // 设置视频 mVideoView.setUp("https://example.com/video.mp4", true, "示例视频"); mVideoView.startPlayLogic(); ``` -------------------------------- ### Synchronous Execution Example Source: https://github.com/706412584/orangeplayer/blob/main/orange-ffmpeg/README.md Example of running a synchronous FFmpeg command. ```java int init = FFmpegKit.init(); int result = FFmpegKit.execute(new String[] { "-i", inputM3U8, "-c", "copy", outputMp4 }); ``` -------------------------------- ### System Player Usage Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/PLAYER_ENGINES.md Switch to the default system player engine and initialize video playback. ```java // 切换到系统播放器 mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_DEFAULT); // 设置视频 mVideoView.setUp("https://example.com/video.mp4", true, "示例视频"); mVideoView.startPlayLogic(); ``` -------------------------------- ### ClassNotFoundException Error Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_CRASH_DIAGNOSIS.md Example of a NoClassDefFoundError indicating a missing dependency. ```text java.lang.NoClassDefFoundError: Failed resolution of: Lcom/shuyu/gsyvideoplayer/... ``` -------------------------------- ### SimpleDownloadManager startDownload Method Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Force start a new download task with a URL, title, and optional description. ```java long startDownload(String url, String title, String description) ``` -------------------------------- ### IJK Player Usage Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/PLAYER_ENGINES.md Switch to the IJK player engine and initialize video playback. ```java // 切换到 IJK mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_IJK); // 设置视频 mVideoView.setUp("rtmp://example.com/live/stream", true, "直播流"); mVideoView.startPlayLogic(); ``` -------------------------------- ### addVideo() usage example Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Demonstrates adding videos to the playlist with and without custom HTTP headers. ```java OrangeVideoController controller = videoView.getVideoController(); // 添加基础视频 controller.addVideo("第1集", "https://example.com/video1.mp4"); controller.addVideo("第2集", "https://example.com/video2.mp4"); // 添加带请求头的视频 HashMap headers = new HashMap<>(); headers.put("Referer", "https://example.com"); controller.addVideo("第3集", "https://example.com/video3.mp4", headers); // 第一个视频会自动设置到播放器,可以直接播放 videoView.startPlayLogic(); ``` -------------------------------- ### Install Debug Build Source: https://github.com/706412584/orangeplayer/blob/main/orange-downloader/README.md Command to install the debug version of the application. ```bash ./gradlew :app:installDebug ``` -------------------------------- ### Asynchronous Execution Example Source: https://github.com/706412584/orangeplayer/blob/main/orange-ffmpeg/README.md Example of running an asynchronous FFmpeg command with a callback. ```java FFmpegKit.executeAsync(new String[] { "-i", inputM3U8, "-c", "copy", outputMp4 }, (code, msg) -> Log.d("FFmpegKit", "code=" + code + ", msg=" + msg)); ``` -------------------------------- ### SecurityException Error Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_CRASH_DIAGNOSIS.md Example of a SecurityException due to missing permissions. ```text java.lang.SecurityException: Permission denied ``` -------------------------------- ### Test app on TV emulator Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_SHARED_CODE_SUMMARY.md Commands to launch the TV emulator, install the mobile app, and monitor logs. ```bash # 启动 TV 模拟器 emulator -avd TV_1080p_API_35 # 安装 app adb -s emulator-5554 install -r app/build/outputs/apk/debug/app-debug.apk # 查看日志 adb -s emulator-5554 logcat | findstr "OrangeApplication\|TvUtils" ``` -------------------------------- ### SimpleDownloadManager startDownloadWithLocalCheck Method Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Start a download with a local check. Returns the local path if already downloaded, or null if not. ```java String startDownloadWithLocalCheck(String url, String title) ``` -------------------------------- ### SpeechSubtitleManager Usage Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/SPEECH_RECOGNITION.md Complete workflow for initializing the manager, setting up translation, handling callbacks, and controlling the speech recognition lifecycle. ```java // 1. 创建管理器 SpeechSubtitleManager manager = new SpeechSubtitleManager(context); // 2. 初始化语音识别 if (SpeechSubtitleManager.isAvailable(context)) { manager.initSpeech("zh-CN"); // 中文 // 3. 初始化翻译(可选) manager.initTranslation("en", new TranslationEngine.ModelDownloadCallback() { @Override public void onSuccess() { Log.d(TAG, "Translation model ready"); } @Override public void onError(String error) { Log.e(TAG, "Translation model download failed: " + error); } @Override public void onProgress(int progress) {} }); } // 4. 设置回调 manager.setCallback(new SpeechSubtitleManager.SpeechSubtitleCallback() { @Override public void onPartialSubtitle(String text, String translatedText) { // 实时显示(可选) subtitleView.setText(text); } @Override public void onFinalSubtitle(String text, String translatedText) { // 显示最终字幕 if (translatedText != null) { subtitleView.setText(text + "\n" + translatedText); } else { subtitleView.setText(text); } } @Override public void onError(String error) { Log.e(TAG, "Speech error: " + error); } }); // 5. 开始/停止 manager.start(); // ... manager.stop(); // 6. 释放 manager.release(); ``` -------------------------------- ### 在代码中切换播放内核 Source: https://github.com/706412584/orangeplayer/blob/main/docs/PLAYER_ENGINES.md 在调用 setUp 之前,使用 selectPlayerFactory 方法设置播放内核。此示例展示了如何根据 PlayerConstants 选择不同的引擎。 ```java import com.orange.playerlibrary.OrangevideoView; import com.shuyu.gsyvideoplayer.player.PlayerConstants; public class MainActivity extends AppCompatActivity { private OrangevideoView mVideoView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mVideoView = findViewById(R.id.video_player); // 选择播放内核(在 setUp 之前调用) selectPlayerEngine(PlayerConstants.ENGINE_EXO); // 设置视频 mVideoView.setUp("https://example.com/video.mp4", true, "示例视频"); mVideoView.startPlayLogic(); } private void selectPlayerEngine(int engine) { switch (engine) { case PlayerConstants.ENGINE_EXO: mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_EXO); break; case PlayerConstants.ENGINE_IJK: mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_IJK); break; case PlayerConstants.ENGINE_DEFAULT: mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_DEFAULT); break; case PlayerConstants.ENGINE_ALI: mVideoView.selectPlayerFactory(PlayerConstants.ENGINE_ALI); break; } } } ``` -------------------------------- ### Initialize Player in Activity Source: https://github.com/706412584/orangeplayer/blob/main/README.md Use the OrangevideoView instance in your Activity to set up the video source and start playback. ```java OrangevideoView videoView = findViewById(R.id.video_player); videoView.setUp("https://example.com/video.mp4", true, "视频标题"); videoView.startPlayLogic(); ``` -------------------------------- ### Install build dependencies Source: https://github.com/706412584/orangeplayer/blob/main/docs/FFMPEG_CUSTOM_BUILD.md Command to install required build tools for OpenSSL compilation on Ubuntu-based systems. ```bash sudo apt install perl make ``` -------------------------------- ### Run debug installation via Gradle Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_QUICK_START.md Use this command in the terminal to install the debug version of the application on the connected TV emulator or device. ```bash ./gradlew installDebug ``` -------------------------------- ### SimpleDownloadManager.startDownloadWithLocalCheck Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Starts a download task with a safety check to prevent duplicate downloads. ```APIDOC ## String startDownloadWithLocalCheck(String url, String title) ### Description Performs a safety check before starting a download. If the video is already downloaded or currently downloading, it intercepts the request. ### Parameters - **url** (String) - Required - The video URL. - **title** (String) - Required - The video title. ### Returns - **String** - Returns the local absolute path if already downloaded, otherwise returns null. ``` -------------------------------- ### Windows Verification Commands Source: https://github.com/706412584/orangeplayer/blob/main/orange-downloader/README.md Commands to install and launch the application on Windows. ```powershell .\gradlew :app:installDebug adb shell am start -n com.orange.player/.MainActivity ``` -------------------------------- ### FFmpegKit usage examples Source: https://github.com/706412584/orangeplayer/blob/main/docs/FFMPEG_CUSTOM_BUILD.md Demonstrates how to download M3U8 files, concatenate video segments, and execute custom FFmpeg commands using the FFmpegKit library. ```java // 下载 m3u8 FFmpegKit.downloadM3U8( "https://example.com/video.m3u8", "/sdcard/Movies/video.mp4", result -> { if (result == 0) { Log.d("FFmpeg", "下载成功"); } else { Log.e("FFmpeg", "下载失败: " + result); } } ); // 合并视频 FFmpegKit.concatVideos(new String[]{ "/sdcard/Movies/part1.ts", "/sdcard/Movies/part2.ts" }, "/sdcard/Movies/merged.mp4"); // 执行自定义命令 FFmpegKit.execute(new String[]{ "-i", "input.mp4", "-vn", "-acodec", "copy", "output.aac" }); ``` -------------------------------- ### Connect and Debug via ADB Source: https://github.com/706412584/orangeplayer/blob/main/app-tv/README.md Commands to connect to a TV over WiFi, install the APK, and view application logs. ```bash # 通过 WiFi 连接(TV 和电脑在同一网络) adb connect :5555 # 安装 APK adb install app-tv/build/outputs/apk/debug/app-tv-debug.apk # 查看日志 adb logcat | findstr "OrangePlayer" ``` -------------------------------- ### Test app-tv on TV emulator Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_SHARED_CODE_SUMMARY.md Commands to compile, install, and monitor logs specifically for the TV-optimized application module. ```bash # 编译安装 gradlew :app-tv:assembleDebug adb -s emulator-5554 install -r app-tv/build/outputs/apk/debug/app-tv-debug.apk # 查看日志 adb -s emulator-5554 logcat | findstr "TvApplication\|OrangePlayerConfig" ``` -------------------------------- ### loadSubtitle() usage example Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Demonstrates loading a subtitle file and handling success or failure callbacks. ```java OrangeVideoController controller = videoView.getVideoController(); controller.loadSubtitle("https://example.com/subtitle.srt", new SubtitleManager.OnSubtitleLoadListener() { @Override public void onLoadSuccess(int count) { Toast.makeText(context, "加载成功,共 " + count + " 条字幕", Toast.LENGTH_SHORT).show(); } @Override public void onLoadFailed(String error) { Toast.makeText(context, "加载失败:" + error, Toast.LENGTH_SHORT).show(); } }); ``` -------------------------------- ### Initialize Basic Video Playback Source: https://github.com/706412584/orangeplayer/blob/main/docs/SDK_INTEGRATION_GUIDE.md Use this snippet to set up and start playing a network video within an OrangevideoView instance. ```java OrangevideoView videoPlayer = findViewById(R.id.video_player); // 播放网络视频 videoPlayer.setUp("https://example.com/video.mp4", true, "视频标题"); videoPlayer.startPlayLogic(); ``` -------------------------------- ### macOS/Linux Verification Commands Source: https://github.com/706412584/orangeplayer/blob/main/orange-downloader/README.md Commands to install and launch the application on macOS or Linux. ```bash ./gradlew :app:installDebug adb shell am start -n com.orange.player/.MainActivity ``` -------------------------------- ### Get Installed Languages Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Retrieve a list of installed language pack codes. ```java List getInstalledLanguages() ``` ```java List installed = manager.getInstalledLanguages(); if (installed.contains("chi_sim")) { Log.d(TAG, "简体中文语言包已安装"); } ``` -------------------------------- ### Check Application Information Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_CRASH_DIAGNOSIS.md ADB commands to verify if the application is installed and to check its version. ```bash # 检查应用是否安装 adb shell pm list packages | findstr orange # 查看应用版本 adb shell dumpsys package com.orange.player.legacy | findstr version ``` -------------------------------- ### Initialize OrangevideoView Source: https://github.com/706412584/orangeplayer/blob/main/docs/promotion/REDDIT_POST.md Basic setup for the OrangevideoView component in your activity or fragment to start video playback. ```java OrangevideoView videoView = findViewById(R.id.video_player); videoView.setUp("https://example.com/video.mp4", true, "Video Title"); videoView.startPlayLogic(); ``` -------------------------------- ### OrangevideoView.setUp() Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Configures the video player with a source URL, caching options, and optional request headers. ```APIDOC ## boolean setUp(String url, boolean cacheWithPlay, String title) ### Description Sets up the video player with the specified URL and basic configuration. ### Parameters - **url** (String) - Required - Video source URL (HTTP/HTTPS/RTSP/Local). - **cacheWithPlay** (boolean) - Required - Whether to cache while playing. - **title** (String) - Required - Video title. ### Returns - **boolean** - true if successful, false otherwise. ``` -------------------------------- ### Verify Fix with APK Build and Logcat Source: https://github.com/706412584/orangeplayer/blob/main/docs/HLS_FIX_SUMMARY.md Build the APK, install it, and monitor logcat for DISCONTINUITY tags to verify the fix. ```bash # 在 Windows 中编译 APK ./gradlew assembleDebug # 安装到设备 adb install -r app/build/outputs/apk/debug/app-debug.apk # 播放异常视频 # URL: https://c1.rrcdnbf6.com/video/sanrenxingbiyouwomei/第01集/index.m3u8 # 观察 logcat 日志 adb logcat | grep -E "DISCONTINUITY|expected_pts|actual_pts" # 应该看到类似的日志: # [hls] Found DISCONTINUITY tag # [hls] Segment with DISCONTINUITY: expected_pts=0s # [mpegts] DISCONTINUITY: expected_pts=0s, actual_pts=1s, offset=1s ``` -------------------------------- ### OutOfMemoryError Error Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_CRASH_DIAGNOSIS.md Example of an OutOfMemoryError due to allocation failure. ```text java.lang.OutOfMemoryError: Failed to allocate a ... byte allocation ``` -------------------------------- ### OrangevideoView.startPlayLogic() Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Initiates the playback process. Must be called after setting the video source. ```APIDOC ## void startPlayLogic() ### Description Triggers the video loading and playback logic. ``` -------------------------------- ### Install GPG on macOS Source: https://github.com/706412584/orangeplayer/blob/main/docs/GPG_SETUP_GUIDE.md Use Homebrew to install the GPG package. ```bash brew install gnupg ``` -------------------------------- ### Implement CastActivity for DLNA casting Source: https://github.com/706412584/orangeplayer/blob/main/docs/CAST_GUIDE.md This example demonstrates the full lifecycle of a casting session, including initializing the CastController, handling device discovery, managing connections, and controlling playback. It requires an OrangevideoView instance and handles UI updates for device lists and connection status via Toast notifications. ```java public class CastActivity extends AppCompatActivity { private OrangevideoView videoView; private CastController castController; private ListView deviceListView; private ArrayAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cast); videoView = findViewById(R.id.video_view); deviceListView = findViewById(R.id.device_list); // 初始化投屏控制器 castController = videoView.getCastController(); // 设置投屏监听 castController.setOnCastListener(new OnCastListener() { @Override public void onDeviceFound(DLNADevice device) { addDeviceToList(device); } @Override public void onConnected(DLNADevice device) { Toast.makeText(CastActivity.this, "已连接到: " + device.getName(), Toast.LENGTH_SHORT).show(); // 投屏当前视频 castController.cast(videoView.getCurrentUrl()); } @Override public void onDisconnected() { Toast.makeText(CastActivity.this, "已断开连接", Toast.LENGTH_SHORT).show(); } @Override public void onError(String error) { Toast.makeText(CastActivity.this, "投屏错误: " + error, Toast.LENGTH_SHORT).show(); } }); // 设备列表点击事件 deviceListView.setOnItemClickListener((parent, view, position, id) -> { DLNADevice device = castController.getDevices().get(position); castController.connectDevice(device); }); // 开始搜索设备 findViewById(R.id.btn_search).setOnClickListener(v -> { castController.startSearch(); Toast.makeText(this, "正在搜索设备...", Toast.LENGTH_SHORT).show(); }); // 停止投屏 findViewById(R.id.btn_stop).setOnClickListener(v -> { castController.stop(); }); } private void addDeviceToList(DLNADevice device) { if (adapter == null) { adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); deviceListView.setAdapter(adapter); } adapter.add(device.getName()); adapter.notifyDataSetChanged(); } @Override protected void onDestroy() { super.onDestroy(); if (castController != null) { castController.stop(); } } } ``` -------------------------------- ### UnsatisfiedLinkError Error Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_CRASH_DIAGNOSIS.md Example of an UnsatisfiedLinkError indicating a missing native library. ```text java.lang.UnsatisfiedLinkError: dlopen failed: library "libijkffmpeg.so" not found ``` -------------------------------- ### Check Language Installation Status Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Check if a specific language pack is installed using its code. ```java boolean isLanguageInstalled(String languageCode) ``` ```java if (manager.isLanguageInstalled("chi_sim")) { // 可以直接使用 startOcr("chi_sim"); } else { // 需要先下载 downloadLanguagePack("chi_sim"); } ``` -------------------------------- ### Implement TvMainFragment using BrowseSupportFragment Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_ADAPTATION_GUIDE.md Extend BrowseSupportFragment to create the main TV browsing interface, including UI setup, data loading with rows, and item click handling. ```java public class TvMainFragment extends BrowseSupportFragment { @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setupUI(); loadData(); } private void setupUI() { // 设置标题 setTitle("OrangePlayer"); // 设置头部颜色 setBrandColor(getResources().getColor(R.color.primary)); // 设置搜索图标 setSearchAffordanceColor(getResources().getColor(R.color.accent)); } private void loadData() { ArrayObjectAdapter rowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); // 添加视频分类 HeaderItem header1 = new HeaderItem(0, "最近播放"); ArrayObjectAdapter listRowAdapter1 = new ArrayObjectAdapter(new VideoCardPresenter()); // 添加视频项... rowsAdapter.add(new ListRow(header1, listRowAdapter1)); HeaderItem header2 = new HeaderItem(1, "推荐视频"); ArrayObjectAdapter listRowAdapter2 = new ArrayObjectAdapter(new VideoCardPresenter()); // 添加视频项... rowsAdapter.add(new ListRow(header2, listRowAdapter2)); setAdapter(rowsAdapter); // 设置点击监听 setOnItemViewClickedListener((itemViewHolder, item, rowViewHolder, row) -> { if (item instanceof Video) { playVideo((Video) item); } }); } private void playVideo(Video video) { Intent intent = new Intent(getActivity(), TvPlayerActivity.class); intent.putExtra("video_url", video.getUrl()); intent.putExtra("video_title", video.getTitle()); startActivity(intent); } } ``` -------------------------------- ### Clean and Install Project via Gradle Source: https://github.com/706412584/orangeplayer/blob/main/docs/IJK_BUILD_WITH_16K_PATCH.md Cleans the project and installs the debug build using Gradle in PowerShell. ```powershell # 在 Windows PowerShell 中 ./gradlew clean ./gradlew :app:installDebug ``` -------------------------------- ### M3U8 Ad Detection Log Example Source: https://github.com/706412584/orangeplayer/blob/main/docs/FAQ.md Example output showing segments parsed and removed by the M3U8 ad remover. ```text D M3U8AdRemover: Ad detected by prefix length at position 120: e57566bf8e40715435.ts D M3U8AdRemover: Total segments parsed: 442 D M3U8AdRemover: Ad segments removed: 7 ``` -------------------------------- ### Create Application.mk Build Configuration Source: https://github.com/706412584/orangeplayer/blob/main/docs/FFMPEG_CUSTOM_BUILD.md This script creates the Application.mk file to specify the target ABI, Android platform version, and C++ standard library settings. ```bash cat > jni-wrapper/jni/Application.mk << 'EOF' APP_ABI := arm64-v8a APP_PLATFORM := android-21 APP_STL := c++_static APP_CPPFLAGS := -std=c++11 EOF ``` -------------------------------- ### OrangevideoView.setUp Source: https://github.com/706412584/orangeplayer/blob/main/README.md The recommended high-level interface to initialize playback for magnet links or local torrent files. ```APIDOC ## void setUp(String url, boolean isLoop, String title) ### Description Configures the video view to play content from a magnet URI or a local torrent file path. ### Parameters - **url** (String) - Required - The magnet URI or the absolute file path to the .torrent file. - **isLoop** (boolean) - Required - Whether the video should loop. - **title** (String) - Required - The display title for the video. ### Usage Example ```java videoView.setUp("magnet:?xt=urn:btih:...", true, "Magnet Video"); videoView.startPlayLogic(); ``` ``` -------------------------------- ### LanguagePackManager API Source: https://github.com/706412584/orangeplayer/blob/main/docs/OCR_GUIDE.md The LanguagePackManager class allows developers to programmatically manage OCR language packs. It supports checking installation status, downloading new packs with progress tracking, listing installed languages, and deleting existing packs. ```APIDOC ## LanguagePackManager ### Description Provides functionality to manage Tesseract OCR language data files. ### Constructor `new LanguagePackManager(Context context)` ### Methods #### isLanguageInstalled(String langCode) - **Returns**: boolean - **Description**: Checks if the specified language pack is installed. #### downloadLanguage(String langCode, DownloadCallback callback) - **Description**: Downloads a language pack. The callback provides progress updates, success, and error handling. #### getInstalledLanguages() - **Returns**: List - **Description**: Returns a list of language codes currently installed. #### getLanguageDisplayName(String langCode) - **Returns**: String - **Description**: Returns the human-readable name for a given language code. #### deleteLanguage(String langCode) - **Returns**: boolean - **Description**: Deletes the specified language pack from storage. ``` -------------------------------- ### 编译与安装命令 Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_MODULE_CREATED.md 用于编译应用并安装到 TV 设备的 Gradle 和 ADB 命令。 ```bash # 编译 gradlew :app-tv:assembleDebug # 安装到 TV 设备 adb install -r app-tv/build/outputs/apk/debug/app-tv-debug.apk # 或使用快捷脚本 run-tv-demo.bat ``` -------------------------------- ### 基础集成配置 Source: https://github.com/706412584/orangeplayer/blob/main/docs/PUBLISH_LEGACY_SDK.md 在项目的 build.gradle 文件中添加 Maven 仓库地址并引入核心库及必要的 CPU 架构支持。可选功能如弹幕和 DLNA 投屏可根据需求添加。 ```gradle // 1. 添加仓库 repositories { mavenCentral() // 或使用 JitPack maven { url 'https://jitpack.io' } } // 2. 添加依赖 dependencies { // 核心库(必需) implementation 'io.github.706412584:orangeplayer:1.1.0-api14' // 选择至少一个 CPU 架构的 so 文件(必需) implementation 'com.shuyu.gsyvideoplayer:gsyVideoPlayer-armv7a:1.0.0' // ARM 32位 implementation 'com.shuyu.gsyvideoplayer:gsyVideoPlayer-armv64:1.0.0' // ARM 64位 // 可选功能 implementation 'com.github.bilibili:DanmakuFlameMaster:0.9.25' // 弹幕 implementation 'com.github.uaoan:UaoanDLNA:1.0.1' // DLNA 投屏(需要 API 19+) } ``` -------------------------------- ### Delete Language Pack Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Remove an installed language pack. ```java boolean deleteLanguage(String languageCode) ``` ```java new AlertDialog.Builder(context) .setTitle("删除语言包") .setMessage("确定要删除简体中文语言包吗?") .setPositiveButton("删除", (dialog, which) -> { if (manager.deleteLanguage("chi_sim")) { Toast.makeText(context, "删除成功", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, "删除失败", Toast.LENGTH_SHORT).show(); } }) .setNegativeButton("取消", null) .show(); ``` -------------------------------- ### 复制 so 文件到项目 Source: https://github.com/706412584/orangeplayer/blob/main/docs/IJKPLAYER_COMPILE_GUIDE.md 将编译好的 so 文件和 Java 源码复制到你的 Android 项目中。 ```bash # 复制到你的项目 cp -r ijkplayer-armv7a/src/main/libs/* your-project/app/src/main/jniLibs/ cp -r ijkplayer-java/src/main/java/* your-project/app/src/main/java/ ``` -------------------------------- ### 复制 SO 文件到项目 Source: https://github.com/706412584/orangeplayer/blob/main/docs/IJK_BUILD_COMPLETED.md 将编译好的 SO 文件复制到 GSYVideoPlayer 项目的 jniLibs 目录中。 ```bash bash scripts/copy_ijk_so.sh ``` -------------------------------- ### 添加 Leanback 依赖到 build.gradle Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_ADAPTATION_GUIDE.md 在项目的 build.gradle 文件中添加 Leanback 库和 TV Provider 依赖,以支持 TV 界面开发。 ```gradle dependencies { // Android TV Leanback 库 implementation 'androidx.leanback:leanback:1.2.0-alpha04' // TV Provider(可选,用于内容推荐) implementation 'androidx.tvprovider:tvprovider:1.0.0' // 现有的播放器依赖 implementation project(':palyerlibrary') // ... } ``` -------------------------------- ### 添加仓库到 settings.gradle Source: https://github.com/706412584/orangeplayer/blob/main/docs/INSTALLATION.md 在项目的 settings.gradle 文件中配置必要的 Maven 仓库,包括 JitPack 和阿里云播放器仓库。 ```gradle dependencyResolutionManagement { repositories { google() mavenCentral() maven { url 'https://jitpack.io' } // 阿里云播放器仓库(如需使用阿里云内核) maven { url 'https://maven.aliyun.com/repository/releases' } } } ``` -------------------------------- ### Subtitle Control Methods Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Methods to start or stop the subtitle display. ```java void start() void stop() ``` ```java // 开始显示字幕 manager.start(); // 暂停字幕显示 manager.stop(); ``` -------------------------------- ### Get Subtitle Count Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Retrieve the total number of subtitle entries. ```java int getSubtitleCount() ``` ```java int count = manager.getSubtitleCount(); if (count > 0) { Log.d(TAG, "已加载 " + count + " 条字幕"); } ``` -------------------------------- ### 上传公钥到 Ubuntu 密钥服务器 Source: https://github.com/706412584/orangeplayer/blob/main/docs/GPG_SETUP_GUIDE.md 将公钥上传至 keyserver.ubuntu.com。 ```powershell gpg --keyserver keyserver.ubuntu.com --send-keys 12345678 ``` -------------------------------- ### 生成发布文件 Source: https://github.com/706412584/orangeplayer/blob/main/docs/MAVEN_CENTRAL_MANUAL_UPLOAD.md 使用 Gradle 构建 AAR、源码 JAR 和文档 JAR。 ```bash # 构建 AAR .\gradlew :palyerlibrary:assembleRelease # 生成源码 JAR .\gradlew :palyerlibrary:androidSourcesJar # 生成文档 JAR .\gradlew :palyerlibrary:androidJavadocsJar ``` -------------------------------- ### sendDanmaku() usage example Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Demonstrates sending plain and colored danmaku messages. ```java // 发送白色弹幕 controller.sendDanmaku("666"); // 发送彩色弹幕 controller.sendDanmaku("红色弹幕", 0xFFFF0000); controller.sendDanmaku("蓝色弹幕", 0xFF0000FF); ``` -------------------------------- ### 扩展编码支持依赖 Source: https://github.com/706412584/orangeplayer/blob/main/docs/INSTALLATION.md 添加扩展 so 库以支持 MPEG 编码、RTSP、concat 和 crypto 协议。 ```gradle dependencies { // 扩展编码支持(支持 mpeg 编码和更多协议,支持 16k Page Size) // 注意:会增加包体积 implementation 'io.github.706412584:gsyVideoPlayer-ex_so:1.1.0' } ``` -------------------------------- ### Execute local release Source: https://github.com/706412584/orangeplayer/blob/main/docs/MAVEN_CENTRAL_SETUP.md Run the appropriate script for your operating system to publish the project. ```bash # Windows publish.bat all # Linux/Mac ./publish.sh all ``` -------------------------------- ### Restart GPG Agent on Linux/macOS Source: https://github.com/706412584/orangeplayer/blob/main/docs/GPG_SETUP_GUIDE.md Kill the GPG agent and start it as a daemon. ```bash gpgconf --kill gpg-agent gpg-agent --daemon ``` -------------------------------- ### 添加 AliyunPlayer 播放器依赖 Source: https://github.com/706412584/orangeplayer/blob/main/docs/OPTIONAL_DEPENDENCIES.md 在 app/build.gradle 文件中引入阿里云播放器 SDK。注意 5.4.x 及以上版本需要 License 授权。 ```gradle dependencies { implementation 'io.github.706412584:orangeplayer:1.0.7' // 阿里云播放器(可选) implementation 'com.aliyun.sdk.android:AliyunPlayer:5.4.7.1-full' } ``` -------------------------------- ### Get Language Display Name Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Retrieve the human-readable name for a language code. ```java static String getLanguageDisplayName(String langCode) ``` ```java String displayName = LanguagePackManager.getLanguageDisplayName("chi_sim"); // 返回 "简体中文" ``` -------------------------------- ### Recompile with new configuration Source: https://github.com/706412584/orangeplayer/blob/main/docs/MISSING_FEATURES_CHECK.md Run the build script to apply the changes made to the configuration file. ```bash bash scripts/build_ijk_with_hls_fix.sh ``` -------------------------------- ### Toggle Controller Visibility Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Example of toggling the controller visibility based on a click event. ```java // 点击屏幕切换控制器显示状态 videoView.setOnClickListener(v -> { if (controller.isShowing()) { controller.hide(); } else { controller.show(); } }); ``` -------------------------------- ### Test Gradle Signing Source: https://github.com/706412584/orangeplayer/blob/main/docs/GPG_SETUP_GUIDE.md Run the build and signing process via Gradle. ```bash # 构建并签名 gradlew clean build sign # 检查签名文件 # 应该生成 .asc 文件 ``` -------------------------------- ### getDanmakuController() usage example Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Demonstrates retrieving the danmaku controller and sending a danmaku message. ```java IDanmakuController danmaku = controller.getDanmakuController(); if (danmaku != null) { danmaku.sendDanmaku("这是一条弹幕", 0xFFFFFFFF); } ``` -------------------------------- ### IJK 播放器 so 库依赖 Source: https://github.com/706412584/orangeplayer/blob/main/docs/INSTALLATION.md 使用 IJK 内核时,需根据目标 CPU 架构添加对应的 so 库依赖。 ```gradle dependencies { // IJK 播放器 so 库(按需添加对应 CPU 架构) implementation 'io.github.706412584:gsyVideoPlayer-arm64:1.1.0' // arm64-v8a(推荐) implementation 'io.github.706412584:gsyVideoPlayer-armv7a:1.1.0' // armeabi-v7a implementation 'io.github.706412584:gsyVideoPlayer-armv5:1.1.0' // armeabi(旧设备) implementation 'io.github.706412584:gsyVideoPlayer-x86:1.1.0' // x86 模拟器 implementation 'io.github.706412584:gsyVideoPlayer-x64:1.1.0' // x86_64 模拟器 } ``` -------------------------------- ### 完整配置(所有架构 + 可选功能) Source: https://github.com/706412584/orangeplayer/blob/main/docs/SDK_INTEGRATION_GUIDE.md 包含所有 CPU 架构支持以及弹幕、DLNA 等可选功能模块。 ```gradle dependencies { // 核心库 implementation 'io.github.706412584:orangeplayer:1.1.0-api14' // 所有 CPU 架构 implementation 'io.github.706412584:gsyVideoPlayer-armv7a:1.1.0-api14' implementation 'io.github.706412584:gsyVideoPlayer-armv64:1.1.0-api14' implementation 'io.github.706412584:gsyVideoPlayer-x86:1.1.0-api14' implementation 'io.github.706412584:gsyVideoPlayer-x86_64:1.1.0-api14' // 可选功能 implementation 'com.github.bilibili:DanmakuFlameMaster:0.9.25' // 弹幕 implementation 'com.github.uaoan:UaoanDLNA:1.0.1' // DLNA(需要 API 19+) implementation 'com.squareup.okhttp3:okhttp:3.12.13' // DLNA 依赖 // MultiDex implementation 'androidx.multidex:multidex:2.0.1' } ``` -------------------------------- ### SimpleDownloadManager.startDownload Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Initiates a new video download task for the specified URL. ```APIDOC ## long startDownload(String url, String title, String description) ### Description Forces the start of a new download task for MP4, FLV, or M3U8 video formats. ### Parameters - **url** (String) - Required - The video URL to download. - **title** (String) - Required - The title used for the saved filename. - **description** (String) - Optional - Additional description information. ### Returns - **long** - The ID of the created download task. ``` -------------------------------- ### Subtitle Control Methods Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Methods for starting, stopping, and configuring subtitle display settings. ```APIDOC ## Subtitle Control Methods ### start() Starts the subtitle display. ### stop() Stops the subtitle display. ### setTextSize(float size) Sets the subtitle font size. - **size** (float) - Required - Font size in sp (12-36). ### getSubtitleCount() Returns the total number of subtitle entries. ``` -------------------------------- ### Start and Stop Speech Recognition Source: https://github.com/706412584/orangeplayer/blob/main/docs/SPEECH_RECOGNITION.md Methods to control the lifecycle of the speech recognition process. ```java /** * 开始语音识别 */ public void start() { if (mIsRunning) return; if (mSpeechEngine == null || !mSpeechEngine.isInitialized()) { Log.e(TAG, "Speech engine not initialized"); return; } mIsRunning = true; mSpeechEngine.startListening(); Log.d(TAG, "Speech subtitle started"); } /** * 停止语音识别 */ public void stop() { mIsRunning = false; if (mSpeechEngine != null) { mSpeechEngine.stopListening(); } Log.d(TAG, "Speech subtitle stopped"); } ``` -------------------------------- ### 编译 OpenSSL 脚本 Source: https://github.com/706412584/orangeplayer/blob/main/docs/FFMPEG_CUSTOM_BUILD.md 创建并执行 build_openssl.sh 脚本,为 arm64 和 arm 架构编译 OpenSSL 静态库。 ```bash cd ~/ffmpeg-build cat > build_openssl.sh << 'EOF' #!/bin/bash NDK_ROOT=~/ffmpeg-build/android-ndk-r21e OPENSSL_SRC=~/ffmpeg-build/openssl-1.1.1w OUTPUT_DIR=~/ffmpeg-build/openssl-android # 目标架构 ARCHS=("arm64" "arm") TRIPLES=("aarch64-linux-android" "arm-linux-androideabi") for i in ${!ARCHS[@]}; do ARCH=${ARCHS[$i]} TRIPLE=${TRIPLES[$i]} echo "Building OpenSSL for $ARCH..." cd $OPENSSL_SRC make clean 2>/dev/null # 设置编译器 export ANDROID_NDK_HOME=$NDK_ROOT export PATH=$NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH # 配置 if [ "$ARCH" = "arm64" ]; then ./Configure android-arm64 \ --prefix=$OUTPUT_DIR/$ARCH \ --openssldir=$OUTPUT_DIR/$ARCH \ no-shared no-tests else ./Configure android-arm \ --prefix=$OUTPUT_DIR/$ARCH \ --openssldir=$OUTPUT_DIR/$ARCH \ no-shared no-tests fi # 编译安装 make -j$(nproc) make install echo "OpenSSL for $ARCH done!" done EOF chmod +x build_openssl.sh ./build_openssl.sh ``` -------------------------------- ### Configure TV Mode in Application and Component Detection Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_INTEGRATION_GUIDE.md Demonstrates how to initialize TV mode settings in the Application class using automatic detection or manual overrides, and how to check the current mode within components. ```java // 在 Application 中 public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); // 方式 1: 自动检测 boolean isTv = TvUtils.isTvDevice(this); OrangePlayerConfig.setTvMode(isTv); // 方式 2: 手动指定 OrangePlayerConfig.setTvMode(true); // 方式 3: 禁用自动检测 OrangePlayerConfig.setAutoDetectTvMode(false); OrangePlayerConfig.setTvMode(false); } } // 在组件中检测 TV 模式 if (OrangePlayerConfig.isTvMode(context)) { // TV 模式逻辑 } else { // 标准模式逻辑 } ``` -------------------------------- ### 运行发布脚本 Source: https://github.com/706412584/orangeplayer/blob/main/maven-central/README.md 从项目根目录或 maven-central 目录下执行 publish.bat 脚本以启动发布流程。 ```bash # 从项目根目录运行 publish.bat ``` ```bash cd maven-central publish.bat ``` -------------------------------- ### 构建验证命令 Source: https://github.com/706412584/orangeplayer/blob/main/docs/LOCAL_GSYVIDEOPLAYER_MIGRATION.md 使用 Gradle 命令验证构建结果及依赖树。 ```bash ./gradlew :app:assembleDebug # BUILD SUCCESSFUL in 1m 15s # APK 大小: 190.98 MB ``` ```bash ./gradlew :app:dependencies --configuration debugRuntimeClasspath ``` -------------------------------- ### 更新 compileSdk 到 36 的操作步骤 Source: https://github.com/706412584/orangeplayer/blob/main/docs/API_AND_MEDIA3_UPDATE_ANALYSIS.md 通过修改子模块的 gradle 配置并提交,使 GSYVideoPlayer 子模块与主项目保持一致,风险极低。 ```bash # 1. 进入子模块 cd GSYVideoPlayer-source # 2. 修改 gradle/base.gradle # 将 compileSdk 35 改为 36 # 3. 提交修改 git add gradle/base.gradle git commit -m "更新 compileSdk 到 36" # 4. 推送到你的 fork git push origin master # 5. 回到主项目 cd .. git add GSYVideoPlayer-source git commit -m "更新 GSYVideoPlayer-source: compileSdk 36" ``` -------------------------------- ### Test app on mobile device Source: https://github.com/706412584/orangeplayer/blob/main/docs/TV_SHARED_CODE_SUMMARY.md Commands to compile, install, and monitor logs for the mobile application. ```bash # 编译安装 gradlew :app:assembleDebug adb install -r app/build/outputs/apk/debug/app-debug.apk # 查看日志 adb logcat | findstr "OrangeApplication\|TvUtils" ``` -------------------------------- ### Test GPG Signing Source: https://github.com/706412584/orangeplayer/blob/main/docs/GPG_SETUP_GUIDE.md Create a test file, sign it, and verify the signature. ```bash # 创建测试文件 echo "test" > test.txt # 签名 gpg --sign test.txt # 验证签名 gpg --verify test.txt.gpg ``` -------------------------------- ### Get Player Manager Source: https://github.com/706412584/orangeplayer/blob/main/palyerlibrary/README.md Retrieve the player manager instance for specific engine types from the videoView. ```java // 获取 ExoPlayer 管理器 OrangeExoPlayerManager exoManager = videoView.getPlayerManager(OrangeExoPlayerManager.class); if (exoManager != null) { // 使用 ExoPlayer 管理器特有功能 } // 获取 IJK 管理器 OrangeIjkPlayerManager ijkManager = videoView.getPlayerManager(OrangeIjkPlayerManager.class); ``` -------------------------------- ### Retrieve and seek to playback history Source: https://github.com/706412584/orangeplayer/blob/main/docs/FAQ.md Use PlayHistoryManager to get the last saved position and seek to it. ```java import com.orange.playerlibrary.history.PlayHistoryManager; PlayHistoryManager manager = PlayHistoryManager.getInstance(context); long position = manager.getHistory(videoUrl); if (position > 0) { videoView.seekTo(position); } ``` -------------------------------- ### 推流性能优化方案 Source: https://github.com/706412584/orangeplayer/blob/main/scripts/README_RTSP.md 针对添加时间戳水印导致的 CPU 负担,提供了三种不同性能需求的推流脚本方案。 ```bash push_rtsp_with_timestamp_fast.bat # 使用 GPU 加速,速度快 5-10 倍 ``` ```bash push_rtsp_with_timestamp.bat # 已优化,降低分辨率和码率 ``` ```bash push_rtsp_stream.bat # 无时间戳,速度最快 ``` -------------------------------- ### Toggle Ad Removal During Playback Source: https://github.com/706412584/orangeplayer/blob/main/docs/API.md Temporarily disable ad removal before starting playback and re-enable it afterwards. ```java // 在播放前关闭去广告功能 M3U8AdManager.getInstance(this).setEnabled(false); // 播放视频 videoView.setUp(videoUrl, true, "视频标题"); videoView.startPlayLogic(); // 播放后重新开启 M3U8AdManager.getInstance(this).setEnabled(true); ```