From 4c1ff7a65d93abd7c8ced7cf506f1bcff05bf3b5 Mon Sep 17 00:00:00 2001 From: jhengazuji Date: Thu, 27 Nov 2025 01:10:44 +0800 Subject: [PATCH] Clean error msg --- .../com/fongmi/android/tv/player/Players.java | 2 +- .../tv/player/exo/ErrorMsgProvider.java | 93 ++++++------------- app/src/main/res/values-zh-rCN/error.xml | 44 --------- app/src/main/res/values-zh-rTW/error.xml | 44 --------- app/src/main/res/values/error.xml | 44 --------- 5 files changed, 30 insertions(+), 197 deletions(-) delete mode 100644 app/src/main/res/values-zh-rCN/error.xml delete mode 100644 app/src/main/res/values-zh-rTW/error.xml delete mode 100644 app/src/main/res/values/error.xml diff --git a/app/src/main/java/com/fongmi/android/tv/player/Players.java b/app/src/main/java/com/fongmi/android/tv/player/Players.java index 755bfb2fa..41d68b79e 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/Players.java +++ b/app/src/main/java/com/fongmi/android/tv/player/Players.java @@ -683,7 +683,7 @@ public class Players implements Player.Listener, ParseCallback { setFormat(ExoUtil.getMimeType(error.errorCode)); break; default: - ErrorEvent.extract(tag, error.getErrorCodeName()); + ErrorEvent.extract(tag, provider.get(error)); break; } } diff --git a/app/src/main/java/com/fongmi/android/tv/player/exo/ErrorMsgProvider.java b/app/src/main/java/com/fongmi/android/tv/player/exo/ErrorMsgProvider.java index 5d19c72d6..57fd0113c 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/exo/ErrorMsgProvider.java +++ b/app/src/main/java/com/fongmi/android/tv/player/exo/ErrorMsgProvider.java @@ -1,74 +1,39 @@ package com.fongmi.android.tv.player.exo; -import android.content.res.Resources; - import androidx.media3.common.PlaybackException; -import androidx.media3.exoplayer.mediacodec.MediaCodecRenderer; -import androidx.media3.exoplayer.mediacodec.MediaCodecUtil; - -import com.fongmi.android.tv.App; -import com.fongmi.android.tv.R; public class ErrorMsgProvider { - private final Resources resources; - - public ErrorMsgProvider() { - this.resources = App.get().getResources(); - } - public String get(PlaybackException e) { - if (e.getCause() instanceof MediaCodecRenderer.DecoderInitializationException e2) return custom(e2); - return resources.getString(getId(e.errorCode)); - } - - private String custom(MediaCodecRenderer.DecoderInitializationException e) { - if (e.codecInfo != null) return resources.getString(R.string.error_instantiating_decoder, e.codecInfo.name); - if (e.getCause() instanceof MediaCodecUtil.DecoderQueryException) return resources.getString(R.string.error_querying_decoders); - else if (e.secureDecoderRequired) return resources.getString(R.string.error_no_secure_decoder, e.mimeType); - else return resources.getString(R.string.error_no_decoder, e.mimeType); - } - - private int getId(int errorCode) { - return switch (errorCode) { - case PlaybackException.ERROR_CODE_REMOTE_ERROR -> R.string.error_remote_error; - case PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW -> R.string.error_behind_live_window; - case PlaybackException.ERROR_CODE_TIMEOUT -> R.string.error_timeout; - case PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK -> R.string.error_failed_runtime_check; - case PlaybackException.ERROR_CODE_IO_UNSPECIFIED -> R.string.error_io_unspecified; - case PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED -> R.string.error_io_network_connection_failed; - case PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT -> R.string.error_io_network_connection_timeout; - case PlaybackException.ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE -> R.string.error_io_invalid_http_content_type; - case PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS -> R.string.error_io_bad_http_status; - case PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND -> R.string.error_io_file_not_found; - case PlaybackException.ERROR_CODE_IO_NO_PERMISSION -> R.string.error_io_no_permission; - case PlaybackException.ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED -> R.string.error_io_cleartext_not_permitted; - case PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE -> R.string.error_io_read_position_out_of_range; - case PlaybackException.ERROR_CODE_PARSING_CONTAINER_MALFORMED -> R.string.error_parsing_container_malformed; - case PlaybackException.ERROR_CODE_PARSING_MANIFEST_MALFORMED -> R.string.error_parsing_manifest_malformed; - case PlaybackException.ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED -> R.string.error_parsing_container_unsupported; - case PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED -> R.string.error_parsing_manifest_unsupported; - case PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> R.string.error_decoder_init_failed; - case PlaybackException.ERROR_CODE_DECODER_QUERY_FAILED -> R.string.error_decoder_query_failed; - case PlaybackException.ERROR_CODE_DECODING_FAILED -> R.string.error_decoding_failed; - case PlaybackException.ERROR_CODE_DECODING_FORMAT_EXCEEDS_CAPABILITIES -> R.string.error_decoding_format_exceeds_capabilities; - case PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED -> R.string.error_decoding_format_unsupported; - case PlaybackException.ERROR_CODE_DECODING_RESOURCES_RECLAIMED -> R.string.error_decoding_resources_reclaimed; - case PlaybackException.ERROR_CODE_AUDIO_TRACK_INIT_FAILED -> R.string.error_audio_track_init_failed; - case PlaybackException.ERROR_CODE_AUDIO_TRACK_WRITE_FAILED -> R.string.error_audio_track_write_failed; - case PlaybackException.ERROR_CODE_AUDIO_TRACK_OFFLOAD_WRITE_FAILED -> R.string.error_audio_track_offload_write_failed; - case PlaybackException.ERROR_CODE_AUDIO_TRACK_OFFLOAD_INIT_FAILED -> R.string.error_audio_track_offload_init_failed; - case PlaybackException.ERROR_CODE_DRM_UNSPECIFIED -> R.string.error_drm_unspecified; - case PlaybackException.ERROR_CODE_DRM_PROVISIONING_FAILED -> R.string.error_drm_provisioning_failed; - case PlaybackException.ERROR_CODE_DRM_CONTENT_ERROR -> R.string.error_drm_content_error; - case PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED -> R.string.error_drm_license_acquisition_failed; - case PlaybackException.ERROR_CODE_DRM_DISALLOWED_OPERATION -> R.string.error_drm_disallowed_operation; - case PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR -> R.string.error_drm_system_error; - case PlaybackException.ERROR_CODE_DRM_DEVICE_REVOKED -> R.string.error_drm_device_revoked; - case PlaybackException.ERROR_CODE_DRM_LICENSE_EXPIRED -> R.string.error_drm_license_expired; - case PlaybackException.ERROR_CODE_VIDEO_FRAME_PROCESSOR_INIT_FAILED -> R.string.error_video_frame_processor_init_failed; - case PlaybackException.ERROR_CODE_VIDEO_FRAME_PROCESSING_FAILED -> R.string.error_video_frame_processing_failed; - default -> R.string.error_unspecified; + return switch (e.errorCode) { + case PlaybackException.ERROR_CODE_UNSPECIFIED -> "Unspecified"; + case PlaybackException.ERROR_CODE_IO_UNSPECIFIED -> "IO Unspecified"; + case PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED -> "Network Connection Failed"; + case PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT -> "Network Connection Timeout"; + case PlaybackException.ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE -> "Invalid HTTP Content Type"; + case PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS -> "Bad HTTP Status"; + case PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE -> "Read Position Out Of Range"; + case PlaybackException.ERROR_CODE_PARSING_CONTAINER_MALFORMED -> "Container Malformed"; + case PlaybackException.ERROR_CODE_PARSING_MANIFEST_MALFORMED -> "Manifest Malformed"; + case PlaybackException.ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED -> "Container Unsupported"; + case PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED -> "Manifest Unsupported"; + case PlaybackException.ERROR_CODE_DECODER_INIT_FAILED -> "Decoder Init Failed"; + case PlaybackException.ERROR_CODE_DECODER_QUERY_FAILED -> "Decoder Query Failed"; + case PlaybackException.ERROR_CODE_DECODING_FAILED -> "Decoding Failed"; + case PlaybackException.ERROR_CODE_DECODING_FORMAT_EXCEEDS_CAPABILITIES -> "Decoding Format Exceeds Capabilities"; + case PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED -> "Decoding Format Unsupported"; + case PlaybackException.ERROR_CODE_DECODING_RESOURCES_RECLAIMED -> "Decoding Resources Reclaimed"; + case PlaybackException.ERROR_CODE_AUDIO_TRACK_INIT_FAILED -> "Audio Track Init Failed"; + case PlaybackException.ERROR_CODE_AUDIO_TRACK_WRITE_FAILED -> "Audio Track Write Failed"; + case PlaybackException.ERROR_CODE_DRM_UNSPECIFIED -> "DRM Unspecified"; + case PlaybackException.ERROR_CODE_DRM_PROVISIONING_FAILED -> "DRM Provisioning Failed"; + case PlaybackException.ERROR_CODE_DRM_CONTENT_ERROR -> "DRM Content Error"; + case PlaybackException.ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED -> "DRM License Acquisition Failed"; + case PlaybackException.ERROR_CODE_DRM_DISALLOWED_OPERATION -> "DRM Disallowed Operation"; + case PlaybackException.ERROR_CODE_DRM_SYSTEM_ERROR -> "DRM System Error"; + case PlaybackException.ERROR_CODE_DRM_DEVICE_REVOKED -> "DRM Device Revoked"; + case PlaybackException.ERROR_CODE_DRM_LICENSE_EXPIRED -> "DRM License Expired"; + default -> e.getErrorCodeName(); }; } } diff --git a/app/src/main/res/values-zh-rCN/error.xml b/app/src/main/res/values-zh-rCN/error.xml deleted file mode 100644 index e6b97f1b7..000000000 --- a/app/src/main/res/values-zh-rCN/error.xml +++ /dev/null @@ -1,44 +0,0 @@ - - 发生未知错误 - 发生远程错误 - 直播内容已过期 - 操作超时 - 系统检查失败 - 发生未知网络错误 - 网络连接失败 - 网络连接超时 - 内容类型无效 - 服务器发生错误 - 找不到文件 - 您没有访问权限 - 不允许不安全的连接 - 无法读取数据 - 媒体文件已损坏 - 媒体信息已损坏 - 不支持的文件格式 - 不支持的媒体类型 - 解码器初始化失败 - 解码器查询失败 - 解码失败 - 解码格式超出设备能力 - 不支持的解码格式 - 解码资源已回收 - 无法初始化音频 - 无法写入音频数据 - 音频硬件解码写入错误 - 音频硬件解码初始化错误 - 未指定的数字版权管理错误 - 数字版权管理配制失败 - 数字版权管理内容错误 - 数字版权管理授权获取失败 - 数字版权管理不允许的操作 - 数字版权管理系统错误 - 数字版权管理设备已撤销 - 数字版权管理授权已过期 - 无法初始化视频处理器 - 视频处理失败 - 此设备不支持 %1$s 格式 - 此设备无法安全播放 %1$s 格式 - 无法查询设备的播放功能 - 无法启用播放组件 %1$s - \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/error.xml b/app/src/main/res/values-zh-rTW/error.xml deleted file mode 100644 index 86f6f9116..000000000 --- a/app/src/main/res/values-zh-rTW/error.xml +++ /dev/null @@ -1,44 +0,0 @@ - - 發生未知錯誤 - 發生遠端錯誤 - 直播內容已過期 - 操作逾時 - 系統檢查失敗 - 發生未知網路錯誤 - 網路連線失敗 - 網路連線逾時 - 內容類型無效 - 伺服器發生錯誤 - 找不到檔案 - 您沒有存取權限 - 不允許不安全的連線 - 無法讀取資料 - 媒體檔案已損毀 - 媒體資訊已損毀 - 不支援的檔案格式 - 不支援的媒體類型 - 解碼器初始化失敗 - 解碼器查詢失敗 - 解碼失敗 - 解碼格式超出裝置能力 - 不支援的解碼格式 - 解碼資源已回收 - 無法初始化音訊 - 無法寫入音訊資料 - 音訊硬體解碼寫入錯誤 - 音訊硬體解碼初始化錯誤 - 未指定的數位版權管理錯誤 - 數位版權管理佈建失敗 - 數位版權管理內容錯誤 - 數位版權管理授權獲取失敗 - 數位版權管理不允許的操作 - 數位版權管理系統錯誤 - 數位版權管理裝置已撤銷 - 數位版權管理授權已過期 - 無法初始化影片處理器 - 影片處理失敗 - 此裝置不支援 %1$s 格式 - 此裝置無法安全播放 %1$s 格式 - 無法查詢裝置的播放功能 - 無法啟用播放元件 %1$s - \ No newline at end of file diff --git a/app/src/main/res/values/error.xml b/app/src/main/res/values/error.xml deleted file mode 100644 index 614842428..000000000 --- a/app/src/main/res/values/error.xml +++ /dev/null @@ -1,44 +0,0 @@ - - An unknown error occurred - A remote error occurred - Content is behind live window - The operation timed out - A system check failed - An unknown network error occurred - Network connection failed - Network connection timed out - Invalid content type - Server error occurred - File not found - You do not have permission to access this - Insecure connection not permitted - Unable to read data - Media file is corrupted - Media info is corrupted - Unsupported file format - Unsupported media type - Decoder initialization failed - Decoder query failed - Decoding failed - Decoding format exceeds capabilities - Unsupported decoding format - Decoding resources reclaimed - Could not initialize audio - Could not write audio data - Audio hardware decoding write error - Audio hardware decoding init error - Unspecified DRM error - DRM provisioning failed - DRM content error - DRM license acquisition failed - DRM disallowed operation - DRM system error - DRM device revoked - DRM license expired - Could not initialize video processor - Video processing failed - This device does not provide a decoder for %1$s - This device does not provide a secure decoder for %1$s - Unable to query device decoders - Unable to instantiate decoder %1$s - \ No newline at end of file