CarGuo / GSYVideoPlayer

视频播放器(IJKplayer、ExoPlayer、MediaPlayer),HTTPS,16k page size,支持弹幕,外挂字幕,支持滤镜、水印、gif截图,片头广告、中间广告,多个同时播放,支持基本的拖动,声音、亮度调节,支持边播边缓存,支持视频自带rotation的旋转(90,270之类),重力旋转与手动旋转的同步支持,支持列表播放 ,列表全屏动画,视频加载速度,列表小窗口支持拖动,动画效果,调整比例,多分辨率切换,支持切换播放器,进度条小窗口预览,列表切换详情页面无缝播放,rtsp、concat、mpeg。
https://juejin.cn/user/817692379985752/posts
Apache License 2.0
20.25k stars 4.2k forks source link

当内核为exoplayer时,如何检测exoplayer的内部错误 #4020

Closed aacai closed 3 months ago

aacai commented 3 months ago

比如,在无UI的播放器,正常播放一个流,在网络关闭时,ExoPlayerImplInternal 会回调一个 Playback error UnknownHostException (no network),但是,此时GSYStateUiListener给我返回的还是2 (playing)状态,

日志 CCodecBuffers com.flyview.airadio D [c2.android.aac.decoder#703:1D-Input.Impl[N]] codec released a buffer owned by client (index 0) 2024-08-21 09:51:54.225 493-5881 CCodecBuffers com.flyview.airadio D [c2.android.aac.decoder#703:1D-Input.Impl[N]] codec released a buffer owned by client (index 0) 2024-08-21 09:51:54.904 493-5881 CCodecBuffers com.flyview.airadio D [c2.android.aac.decoder#703:1D-Input.Impl[N]] codec released a buffer owned by client (index 0) 2024-08-21 09:51:55.015 493-23986 BufferPoolAccessor com.flyview.airadio D bufferpool2 0xbf181a10 : 6(49152 size) total buffers - 5(40960 size) used buffers - 1/7 (recycle/alloc) - 6/1287 (fetch/transfer) //关闭网络 2024-08-21 09:51:58.294 493-23952 ExoPlayerImplInternal com.flyview.airadio E Playback error UnknownHostException (no network) 2024-08-21 09:51:58.295 493-23952 android.me...AudioTrack com.flyview.airadio D AudioTrack.pause 2024-08-21 09:51:58.299 493-23986 Codec2Client com.flyview.airadio W query -- param skipped: index = 1342179345. 2024-08-21 09:51:58.299 493-23986 Codec2Client com.flyview.airadio W query -- param skipped: index = 2415921170. 2024-08-21 09:51:58.299 493-23986 Codec2Client com.flyview.airadio W query -- param skipped: index = 1610614798. 2024-08-21 09:51:58.304 493-25665 android.me...AudioTrack com.flyview.airadio D AudioTrack.stop 2024-08-21 09:51:58.304 493-25665 android.me...AudioTrack com.flyview.airadio D AudioTrack.release 2024-08-21 09:51:58.313 493-493 EventLogger com.flyview.airadio E playerFailed [30.64] 2024-08-21 09:51:58.314 493-493 EventLogger com.flyview.airadio D loading [false] 2024-08-21 09:51:58.314 493-493 EventLogger com.flyview.airadio D state [30.64, I] 2024-08-21 09:51:58.316 493-493 ExoPlayerImpl com.flyview.airadio I Release fab3927 [AndroidXMedia3/1.4.0] [mercury-demo, QUAD-CORE T507, Allwinner, 29] [media3.common, media3.exoplayer.hls, media3.exoplayer, media3.decoder, media3.datasource, media3.extractor] 2024-08-21 09:52:38.906 493-509

CarGuo commented 3 months ago
@Override
                public void onPlayError(String url, Object... objects) {
                    super.onPlayError(url, objects);
                    if (objects[2] != null && binding.detailPlayer.getGSYVideoManager().getPlayer() instanceof Exo2PlayerManager) {
                        Debuger.printfError("#######################");
                        int code = ((int) objects[2]);
                        String errorStatus = "****";
                        switch (code) {
                            case ERROR_CODE_UNSPECIFIED:
                                errorStatus = "ERROR_CODE_UNSPECIFIED";
                                break;
                            case ERROR_CODE_REMOTE_ERROR:
                                errorStatus = "ERROR_CODE_REMOTE_ERROR";
                                break;
                            case ERROR_CODE_BEHIND_LIVE_WINDOW:
                                errorStatus = "ERROR_CODE_BEHIND_LIVE_WINDOW";
                                break;
                            case ERROR_CODE_TIMEOUT:
                                errorStatus = "ERROR_CODE_TIMEOUT";
                                break;
                            case ERROR_CODE_FAILED_RUNTIME_CHECK:
                                errorStatus = "ERROR_CODE_FAILED_RUNTIME_CHECK";
                                break;
                            case ERROR_CODE_IO_UNSPECIFIED:
                                errorStatus = "ERROR_CODE_IO_UNSPECIFIED";
                                break;
                            case ERROR_CODE_IO_NETWORK_CONNECTION_FAILED:
                                errorStatus = "ERROR_CODE_IO_NETWORK_CONNECTION_FAILED";
                                break;
                            case ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT:
                                errorStatus = "ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT";
                                break;
                            case ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE:
                                errorStatus = "ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE";
                                break;
                            case ERROR_CODE_IO_BAD_HTTP_STATUS:
                                errorStatus = "ERROR_CODE_IO_BAD_HTTP_STATUS";
                                break;
                            case ERROR_CODE_IO_FILE_NOT_FOUND:
                                errorStatus = "ERROR_CODE_IO_FILE_NOT_FOUND";
                                break;
                            case ERROR_CODE_IO_NO_PERMISSION:
                                errorStatus = "ERROR_CODE_IO_NO_PERMISSION";
                                break;
                            case ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED:
                                errorStatus = "ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED";
                                break;
                            case ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE:
                                errorStatus = "ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE";
                                break;
                            case ERROR_CODE_PARSING_CONTAINER_MALFORMED:
                                errorStatus = "ERROR_CODE_PARSING_CONTAINER_MALFORMED";
                                break;
                            case ERROR_CODE_PARSING_MANIFEST_MALFORMED:
                                errorStatus = "ERROR_CODE_PARSING_MANIFEST_MALFORMED";
                                break;
                            case ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED:
                                errorStatus = "ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED";
                                break;
                            case ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED:
                                errorStatus = "ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED";
                                break;
                            case ERROR_CODE_DECODER_INIT_FAILED:
                                errorStatus = "ERROR_CODE_DECODER_INIT_FAILED";
                                break;
                            case ERROR_CODE_DECODER_QUERY_FAILED:
                                errorStatus = "ERROR_CODE_DECODER_QUERY_FAILED";
                                break;
                            case ERROR_CODE_DECODING_FAILED:
                                errorStatus = "ERROR_CODE_DECODING_FAILED";
                                break;
                            case ERROR_CODE_DECODING_FORMAT_EXCEEDS_CAPABILITIES:
                                errorStatus = "ERROR_CODE_DECODING_FORMAT_EXCEEDS_CAPABILITIES";
                                break;
                            case ERROR_CODE_DECODING_FORMAT_UNSUPPORTED:
                                errorStatus = "ERROR_CODE_DECODING_FORMAT_UNSUPPORTED";
                                break;
                            case ERROR_CODE_AUDIO_TRACK_INIT_FAILED:
                                errorStatus = "ERROR_CODE_AUDIO_TRACK_INIT_FAILED";
                                break;
                            case ERROR_CODE_AUDIO_TRACK_WRITE_FAILED:
                                errorStatus = "ERROR_CODE_AUDIO_TRACK_WRITE_FAILED";
                                break;
                            case ERROR_CODE_DRM_UNSPECIFIED:
                                errorStatus = "ERROR_CODE_DRM_UNSPECIFIED";
                                break;
                            case ERROR_CODE_DRM_SCHEME_UNSUPPORTED:
                                errorStatus = "ERROR_CODE_DRM_SCHEME_UNSUPPORTED";
                                break;
                            case ERROR_CODE_DRM_PROVISIONING_FAILED:
                                errorStatus = "ERROR_CODE_DRM_PROVISIONING_FAILED";
                                break;
                            case ERROR_CODE_DRM_CONTENT_ERROR:
                                errorStatus = "ERROR_CODE_DRM_CONTENT_ERROR";
                                break;
                            case ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED:
                                errorStatus = "ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED";
                                break;
                            case ERROR_CODE_DRM_DISALLOWED_OPERATION:
                                errorStatus = "ERROR_CODE_DRM_DISALLOWED_OPERATION";
                                break;
                            case ERROR_CODE_DRM_SYSTEM_ERROR:
                                errorStatus = "ERROR_CODE_DRM_SYSTEM_ERROR";
                                break;
                            case ERROR_CODE_DRM_DEVICE_REVOKED:
                                errorStatus = "ERROR_CODE_DRM_DEVICE_REVOKED";
                                break;
                            case ERROR_CODE_DRM_LICENSE_EXPIRED:
                                errorStatus = "ERROR_CODE_DRM_LICENSE_EXPIRED";
                                break;
                            case CUSTOM_ERROR_CODE_BASE:
                                errorStatus = "CUSTOM_ERROR_CODE_BASE";
                                break;
                        }
                        Debuger.printfError(errorStatus);
                        Debuger.printfError("#######################");
                    }
                }
aacai commented 2 months ago
    Log.d(TAG, "onPlayError: 参数:${objects.getOrNull(0)},下一个:${objects.getOrNull(1)},第三个:${objects.getOrNull(2)}")

打印出来是onPlayError: 参数:,下一个:com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer{260d3e6 V.E...... ......I. 0,0-0,0},第三个:null,不对。 而且,没有UI,无法回调onClickStartError这种方法,我无法知道playState是什么时候更新的(onPlayStateChanged),目前只能反射里面的exoplayer