ksvc / KSYMediaPlayer_Android

金山云Android播放SDK(KSYUN Live Streaming player SDK),支持RTMP HTTP-FLV HLS 协议(supporting RTMP HTTP-FLV HLS protocol),直播延时2-3秒(Living delay 2 or 3 seconds),supporting jitter control,software&hardware decode
http://v.ksyun.com/
Apache License 2.0
855 stars 247 forks source link

# Thread-10200(10200) SIGSEGV(SEGV_MAPERR) #206

Open lin126 opened 6 years ago

lin126 commented 6 years ago
网络APN Wi-Fi 是否ROOT
可用内存大小 817.17 MB ( 21.69% ) 可用存储空间 12.18 GB ( 22.17% )
可用SD卡大小 12.13 GB ( 22.10% ) Bugly SDK版本号 2.6.5
ROM详情 Oppo/COLOROS/V3.0.0
Bugly NDK版本号 2.2.0

1 #00 pc 0000000000204c7c /data/app/com.tb.teachOnLine-2/lib/arm64/libksyplayer.so (avio_read+44) [arm64-v8a]

2 #01 pc 000000000023ba38 /data/app/com.tb.teachOnLine-2/lib/arm64/libksyplayer.so [arm64-v8a]

1-29 21:22:01.125 11496 16693 I KSYMediaPlayer: android-pipeline:destroy, will release java byte array: 0

2811-29 21:22:01.128 11496 16693 E KSYMediaPlayer: SDL_JNI_ThreadDestroyed: [16693] didn't call SDL_JNI_DetachThreadEnv() explicity 2911-29 21:22:01.888 11496 13475 D libc-netbsd: getaddrinfo: fda333de-aea7-4803-b296-6befae50.ksyunacc.cn get result from proxy >> 3011-29 21:22:01.942 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 3111-29 21:22:01.942 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 3211-29 21:22:01.942 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=80; cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=0; ai_family=0 3311-29 21:22:01.943 11496 16720 D libc-netbsd: getaddrinfo: k16speedvideo.knowle.cn get result from proxy >> 3411-29 21:22:01.957 11496 13475 D libc-netbsd: [getaddrinfo]: mtk hostname=fda333de-aea7-4803-b296-6befae50.ksyunacc.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 3511-29 21:22:02.050 11496 13475 E NativeCrypto: ssl=0x7f6a1df380 cert_verify_callback x509_store_ctx=0x7f68bfee38 arg=0x0 3611-29 21:22:02.050 11496 13475 E NativeCrypto: ssl=0x7f6a1df380 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA 3711-29 21:22:02.325 11496 13475 D libc-netbsd: [getaddrinfo]: mtk hostname=fda333de-aea7-4803-b296-6befae50.ksyunacc.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 3811-29 21:22:02.446 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 3911-29 21:22:02.446 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 4011-29 21:22:02.446 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=80; cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=0; ai_family=0 4111-29 21:22:02.447 11496 16720 D libc-netbsd: getaddrinfo: k16speedvideo.knowle.cn get result from proxy >> 4211-29 21:22:02.511 11496 11496 W com.ksyun.media.player.KSYMediaPlayer: KSYMediaPlayer went away with unhandled events 4311-29 21:22:03.767 11496 16720 I KSYMediaPlayer: SDL_Android_AudioTrack: CHANNEL_OUT_MONO 4411-29 21:22:03.768 11496 16720 I KSYMediaPlayer: SDL_Android_AudioTrack: ENCODING_PCM_16BIT 4511-29 21:22:03.770 11496 16720 I KSYMediaPlayer: [zzy][a]SDL_Android_AudioTrack_new_from_spec: audio track buffer size:4458 4611-29 21:22:03.771 11496 16720 I KSYMediaPlayer: SDL_Android_AudioTrack_new_from_spec: init volume as 1.000000/(1.000000,0.000000) 4711-29 21:22:03.771 11496 16720 I KSYMediaPlayer: [zzy][a]aout_open_audio_n, buffer_size:4458 4811-29 21:22:03.771 11496 16720 I KSYMediaPlayer: audio_session_id = 1186 4911-29 21:22:03.778 11496 11496 D com.ksyun.media.player.KSYMediaPlayer: KSYMediaPlayer Use Software Decode and SDK Version is:2.0.0, BufferTimeMax:3600.0 5011-29 21:22:03.841 11496 16742 I KSYMediaPlayer: not enable filter w3fdif 5111-29 21:22:03.841 11496 16742 D KSYMediaPlayer: SDL_VoutFFmpeg_CreateOverlay(w=1280, h=720, fmt=I420(0x30323449, dp=0x7f835303d0) 5211-29 21:22:03.842 11496 16742 D KSYMediaPlayer: Video: first frame decoded 5311-29 21:22:03.843 11496 16742 D KSYMediaPlayer: SDL_VoutFFmpeg_CreateOverlay(w=1280, h=720, fmt=I420(0x30323449, dp=0x7f835303d0) 5411-29 21:22:03.845 11496 16742 D KSYMediaPlayer: SDL_VoutFFmpeg_CreateOverlay(w=1280, h=720, fmt=I420(0x30323449, dp=0x7f835303d0) 5511-29 21:22:03.850 11496 16719 I KSYMediaPlayer: [EGL] eglInitialize 1.4 5611-29 21:22:03.852 11496 16719 I KSYMediaPlayer: [EGL] ANativeWindow_setBuffersGeometry(f=2); 5711-29 21:22:03.853 11496 11642 D libc-netbsd: [getaddrinfo]: mtk hostname=trace-ldns.ksyun.com; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 5811-29 21:22:03.853 11496 11642 D libc-netbsd: [getaddrinfo]: mtk hostname=trace-ldns.ksyun.com; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 5911-29 21:22:03.856 11496 11496 D Dialog : handleMessage:{ when=-24ms what=67 obj=com.mingle.widget.ShapeLoadingDialog$1@b53249a target=android.app.Dialog$ListenersHandler obj=com.mingle.widget.ShapeLoadingDialog$1@b53249a } 6011-29 21:22:03.856 11496 16719 I KSYMediaPlayer: [GLES2] Version = OpenGL ES 3.1 6111-29 21:22:03.857 11496 16719 I KSYMediaPlayer: [GLES2] Vendor = ARM 6211-29 21:22:03.857 11496 16719 I KSYMediaPlayer: [GLES2] Renderer = Mali-T860 6311-29 21:22:03.857 11496 16719 I KSYMediaPlayer: [GLES2] Extensions = GL_EXT_debug_marker GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture GL_OES_surfaceless_context GL_OES_texture_s 6411-29 21:22:03.857 11496 16719 I KSYMediaPlayer: create render yuv420p 6511-29 21:22:03.860 11496 16719 I KSYMediaPlayer: use render yuv420p 6611-29 21:22:03.865 11496 11642 D libc-netbsd: getaddrinfo: trace-ldns.ksyun.com get result from proxy >> 6711-29 21:22:03.866 11496 16719 I KSYMediaPlayer: [yuv420p] padding changed: 1280 - 1280 = 0 (0.000000) 6811-29 21:22:03.934 11496 11642 D libc-netbsd: [getaddrinfo]: mtk hostname=trace-ldns.ksyun.com; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 6911-29 21:22:04.005 11496 11642 E NativeCrypto: ssl=0x7f5f3da780 cert_verify_callback x509_store_ctx=0x7f79636e38 arg=0x0 7011-29 21:22:04.005 11496 11642 E NativeCrypto: ssl=0x7f5f3da780 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA 7111-29 21:22:04.146 11496 11642 D libc-netbsd: [getaddrinfo]: mtk hostname=0ee6a918-5932-492b-a203-d8f36ecb.ksyunacc.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 7211-29 21:22:04.146 11496 11642 D libc-netbsd: [getaddrinfo]: mtk hostname=0ee6a918-5932-492b-a203-d8f36ecb.ksyunacc.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 7311-29 21:22:07.000 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ......I. 0,0-1920,1080 #7f0c00a1 app:id/video_view} 7411-29 21:22:07.003 11496 11496 I SurfaceView: Punch a hole(dispatchDraw), w = 1920, h = 1080, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 7511-29 21:22:07.060 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 7611-29 21:22:07.151 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 7711-29 21:22:07.857 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 7811-29 21:22:08.846 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 7911-29 21:22:09.857 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 8011-29 21:22:10.006 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 8111-29 21:22:12.072 11496 16857 D libc-netbsd: [getaddrinfo]: mtk hostname=videodev.ksyun.com; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 8211-29 21:22:12.072 11496 16857 D libc-netbsd: [getaddrinfo]: mtk hostname=videodev.ksyun.com; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 8311-29 21:22:12.284 11496 16857 D libc-netbsd: getaddrinfo: videodev.ksyun.com get result from proxy >> 8411-29 21:22:12.928 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 8511-29 21:22:12.960 11496 16857 D libc-netbsd: [getaddrinfo]: mtk hostname=videodev.ksyun.com; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 8611-29 21:22:13.847 11496 16857 E NativeCrypto: ssl=0x7f6a1de580 cert_verify_callback x509_store_ctx=0x7f6cb01ee8 arg=0x0 8711-29 21:22:13.848 11496 16857 E NativeCrypto: ssl=0x7f6a1de580 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA 8811-29 21:22:13.852 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 8911-29 21:22:14.034 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 9011-29 21:22:14.178 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 9111-29 21:22:14.906 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 9211-29 21:22:15.026 11496 16857 D KsyHttpClient: https response code: 200 response message : OK 9311-29 21:22:15.075 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 9411-29 21:22:15.847 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 9511-29 21:22:15.882 11496 11496 D AbsSeekBar: onStartTrackingTouch 9611-29 21:22:16.863 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 9711-29 21:22:17.659 11496 11496 D AbsSeekBar: onStopTrackingTouch 9811-29 21:22:17.862 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 9911-29 21:22:18.079 11496 11496 I SurfaceView: updateWindow -- setFrame, this = android.view.SurfaceView{1f1fefd0 V.E..... ........ 0,0-1920,1080 #7f0c00a1 app:id/video_view} 10011-29 21:22:18.699 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 10111-29 21:22:18.699 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 10211-29 21:22:18.699 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=80; cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=0; ai_family=0 10311-29 21:22:18.702 11496 16720 D libc-netbsd: getaddrinfo: k16speedvideo.knowle.cn get result from proxy >> 10411-29 21:22:23.882 11496 11496 D Dialog : handleMessage:{ when=-4ms what=67 obj=com.mingle.widget.ShapeLoadingDialog$1@b53249a target=android.app.Dialog$ListenersHandler obj=com.mingle.widget.ShapeLoadingDialog$1@b53249a } 10511-29 21:22:23.934 11496 11496 E com.ksyun.media.player.KSYMediaPlayer: Error (-10011,0) 10611-29 21:22:23.935 11496 16571 D libc-netbsd: [getaddrinfo]: mtk hostname=cname.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 10711-29 21:22:23.936 11496 16571 D libc-netbsd: [getaddrinfo]: mtk hostname=cname.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0 10811-29 21:22:23.940 11496 16571 D libc-netbsd: getaddrinfo: cname.knowle.cn get result from proxy >> 10911-29 21:22:23.946 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 11011-29 21:22:23.946 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=(null); cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 11111-29 21:22:23.947 11496 16720 D libc-netbsd: [getaddrinfo]: mtk hostname=k16speedvideo.knowle.cn; servname=80; cache_mode=(null), netid=0; mark=0; app_uid=10035; ai_addrlen=0; ai_canonname=(null); ai_flags=0; ai_family=0 11211-29 21:22:23.949 11496 16720 D libc-netbsd: getaddrinfo: k16speedvideo.knowle.cn get result from proxy >> 11311-29 21:22:30.286 11496 16720 E CrashReport: Bugly NDK Version:2.2.0 11411-29 21:22:30.287 11496 16720 E CrashReport: Old handler addresss 0x7fa58da660 11511-29 21:22:30.287 11496 16720 E CrashReport: HandleSignal start 11 11611-29 21:22:30.459 11496 16720 E CrashReport: Native log has not been initiated.

FirmianaRain commented 6 years ago
  1. 请问播放版本是多少
  2. 播放已经报错 -10011,请问后续有什么操作吗?
lin126 commented 6 years ago

1, 播放器版本, 目前不知道怎么查询版本号。 2, 关于操作:

017-11-29 20:37:54 com.tb.teachOnLine.navigation.WelcomeActivity onCreated

12017-11-29 20:37:55 com.tb.teachOnLine.navigation.WelcomeActivity onResumed 22017-11-29 20:38:00 com.tb.teachOnLine.navigation.WelcomeActivity onPaused 32017-11-29 20:38:00 com.tb.teachOnLine.main.view.MainActivity onCreated 42017-11-29 20:38:00 com.tb.teachOnLine.main.view.MainActivity onResumed 52017-11-29 20:38:00 com.tb.teachOnLine.navigation.WelcomeActivity onDestroyed 62017-11-29 20:38:12 com.tb.teachOnLine.main.view.MainActivity onPaused 72017-11-29 20:38:12 com.tb.teachOnLine.main.view.CourseDetailsActivity onCreated 82017-11-29 20:38:12 com.tb.teachOnLine.main.view.CourseDetailsActivity onResumed 92017-11-29 20:38:16 com.tb.teachOnLine.main.view.CourseDetailsActivity onPaused 102017-11-29 20:38:17 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 112017-11-29 20:38:17 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 122017-11-29 20:39:00 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 132017-11-29 20:39:00 com.tb.teachOnLine.main.view.CourseDetailsActivity onResumed 142017-11-29 20:39:00 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 152017-11-29 20:39:02 com.tb.teachOnLine.main.view.CourseDetailsActivity onPaused 162017-11-29 20:39:02 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 172017-11-29 20:39:02 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 182017-11-29 20:39:48 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 192017-11-29 20:39:49 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 202017-11-29 20:39:49 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 212017-11-29 20:39:49 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 222017-11-29 20:39:49 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 232017-11-29 20:40:01 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 242017-11-29 20:40:01 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 252017-11-29 20:40:01 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 262017-11-29 20:40:02 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 272017-11-29 20:40:02 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 282017-11-29 20:40:35 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 292017-11-29 20:40:36 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 302017-11-29 20:40:36 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 312017-11-29 20:40:36 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 322017-11-29 20:40:36 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 332017-11-29 20:40:47 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 342017-11-29 20:40:47 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 352017-11-29 20:40:47 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 362017-11-29 20:40:47 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 372017-11-29 20:40:47 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 382017-11-29 20:41:21 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 392017-11-29 20:41:21 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 402017-11-29 20:41:21 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 412017-11-29 20:41:22 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 422017-11-29 20:41:22 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 432017-11-29 20:41:30 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 442017-11-29 20:41:30 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 452017-11-29 20:41:30 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 462017-11-29 20:41:30 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 472017-11-29 20:41:30 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 482017-11-29 20:41:46 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 492017-11-29 20:41:46 com.tb.teachOnLine.main.view.CourseDetailsActivity onResumed 502017-11-29 20:41:46 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 512017-11-29 20:42:16 com.tb.teachOnLine.main.view.CourseDetailsActivity onPaused 522017-11-29 20:42:53 com.tb.teachOnLine.main.view.CourseDetailsActivity onResumed 532017-11-29 20:43:18 com.tb.teachOnLine.main.view.CourseDetailsActivity onPaused 542017-11-29 20:43:18 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 552017-11-29 20:43:18 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 562017-11-29 21:12:41 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 572017-11-29 21:16:25 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 582017-11-29 21:21:52 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 592017-11-29 21:21:53 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 602017-11-29 21:21:53 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 612017-11-29 21:21:53 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 622017-11-29 21:21:53 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 632017-11-29 21:22:00 com.tb.teachOnLine.video.IJKPlayerActivity onResumed 642017-11-29 21:22:00 com.tb.teachOnLine.video.IJKPlayerActivity onPaused 652017-11-29 21:22:00 com.tb.teachOnLine.video.IJKPlayerActivity onDestroyed 662017-11-29 21:22:00 com.tb.teachOnLine.video.IJKPlayerActivity onCreated 672017-11-29 21:22:00 com.tb.teachOnLine.video.IJKPlayerActivity onResumed

lin126 commented 6 years ago

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="demo.playerlib" android:versionCode="1" android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="23" />

<application
    android:allowBackup="true"
    android:label="@string/app_name"
    android:supportsRtl="true" >
</application>

FirmianaRain commented 6 years ago
  1. 接口是getVersion
  2. 我看最初的崩溃日志,播放器已经报错了,后续你们有什么操作?代码是怎么处理的?
lin126 commented 6 years ago

1, 版本应该是1.0 2, 我这边没有做任何处理

这是用户那边操作导致的问题,我这边是通过远程bugly收集到时的信息,应为是crash在so里面, 我想知道出现的原因是什么?或者我再哪里可以继续帮你们查一下是什么原因?

FirmianaRain commented 6 years ago
  1. 我是指SDK的版本
  2. 播放器报错了没做处理?比如重连或者重新播放?
lin126 commented 6 years ago

1,SDK版本为:2.0.0 2,这个是我这边操作的代码

package com.tb.teachOnLine.video;

import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.media.AudioManager; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.GestureDetector; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.webkit.JavascriptInterface; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; import android.widget.Toast; import com.ksyun.media.player.IMediaPlayer; import com.ksyun.media.player.KSYMediaPlayer; import com.mingle.widget.ShapeLoadingDialog; import com.netease.nimlib.sdk.NIMClient; import com.netease.nimlib.sdk.Observer; import com.netease.nimlib.sdk.RequestCallback; import com.netease.nimlib.sdk.StatusCode; import com.netease.nimlib.sdk.auth.AuthService; import com.netease.nimlib.sdk.auth.AuthServiceObserver; import com.netease.nimlib.sdk.auth.LoginInfo; import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder; import com.netease.nimlib.sdk.chatroom.ChatRoomService; import com.netease.nimlib.sdk.chatroom.ChatRoomServiceObserver; import com.netease.nimlib.sdk.chatroom.model.ChatRoomInfo; import com.netease.nimlib.sdk.chatroom.model.ChatRoomKickOutEvent; import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage; import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomData; import com.netease.nimlib.sdk.msg.MsgService; import com.tb.teachOnLine.R; import com.tb.teachOnLine.Utils.KeyBoardUtils; import com.tb.teachOnLine.Utils.PadUtils; import com.tb.teachOnLine.Utils.RadiusUtils; import com.tb.teachOnLine.Utils.ScreenUtils; import com.tb.teachOnLine.Utils.UserInfoUtils; import com.tb.teachOnLine.Utils.VideoUtils; import com.tb.teachOnLine.bean.ClassPracticeBean; import com.tb.teachOnLine.bean.CustomAttachParser; import com.tb.teachOnLine.bean.MeetingInfoBean; import com.tb.teachOnLine.bean.RtmpBean; import com.tb.teachOnLine.bean.VodUrlBean; import com.tb.teachOnLine.listener.ClassPracticeListener; import com.tb.teachOnLine.listener.RtmpListener; import com.tb.teachOnLine.listener.VodUrlListener; import com.tb.teachOnLine.main.adapter.IMMessageAdapter; import com.tb.teachOnLine.manager.OkHttpClientManager; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.Timer; import java.util.TimerTask;

public class IJKPlayerActivity extends Activity implements View.OnClickListener, SeekBar.OnSeekBarChangeListener { private String path; private boolean isReadly = true; private ViewGroup mVgTop; private RelativeLayout mBtnBack; private TextView mTvTitle; private boolean isRtmpNormal; private ViewGroup mVgBottom; private ImageButton mBtnPlayOrPauseDemand; private TextView mTvCurrentTime; private TextView mTvTotalTime; private SeekBar mSeekbar; private boolean mbIsLive = true; private boolean mbIsPlaying = false; private String mCourseTitle; private VideoThread thread; private String isliVe = "isNotLive"; private boolean isFoldFlag = false; private VideoControllerTimer mVideoControllerTimer; private TextView mLoadTv; private ImageView mVideoDefault; private ImageButton mBackImg; private RelativeLayout mVideoLoadingContainer; private RelativeLayout mLiveRlVideoBottomC; private TextView mChangeTv; private ListView mListView; private boolean isCanSpeak = true; private RelativeLayout mChangeContainer; private List changeList; private HashMap<Integer, TextView> map = new HashMap<>(); private String courseId; private VodUrlBean.Data vodUrlData; private String errmsg; private List rtmpDataList; private int rtmpCurrentPosition; private LinearLayout mTextHintContainer; public long startTime; private ShapeLoadingDialog shapeLoadingDialog; private String meetingId; private MeetingInfoBean.Data meetingInfoData; private ListView imListView; private TextView sendTv; private EditText et; private boolean isSendReport = false; private Timer timer; private int randomTime; private RelativeLayout rightContainer; private TextView bottomText, topText; private int i2; private ReportTimerTask task; private boolean isExit; private boolean isScrollBottom = true; private boolean isOnDestory = false; private RelativeLayout mRootView; private WebView rollCallWv; private WebView questionWebView; private WebView startQuizWv; private WebView resultsOfQuizWv; private WebView startExerciseWv; private boolean isKicout = false; private boolean isSubmitExercise = false; private String cid;//课程id private long recordPlayTime; private int sendPlayWatchTime; private boolean isCanPalyVod;//是否能看点播 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ijk); try { Intent intent = getIntent(); mCourseTitle = intent.getStringExtra(VideoUtils.VIDEO_NAME); isliVe = intent.getStringExtra(VideoUtils.VIDEO_IS_LIVE); courseId = intent.getStringExtra(VideoUtils.COURSE_ID);

        _initView();
        _initData();
        _setViewListener();
        _updateBtnPlayPauseBg(R.drawable.video_player_play_bg);
        if (isliVe.equals("isLive")) {
            meetingId = intent.getStringExtra(VideoUtils.VIDEO_MEETING_ID);
            mbIsLive = true;
            RtmpCallback callback = new RtmpCallback();
            OkHttpClientManager.getInstance().setRtmpListener(callback);
            OkHttpClientManager.getInstance().joinMeeting(meetingId);
        } else if (isliVe.equals("demoVideo")) {
            rightContainer.setVisibility(View.GONE);
            mbIsLive = false;
            path = intent.getStringExtra(VideoUtils.VIDEO_URL);
            initPlayer();
        } else {
            cid = intent.getStringExtra(VideoUtils.VIDEO_CID);
            rightContainer.setVisibility(View.GONE);
            mbIsLive = false;
            VodUrlCallback callback = new VodUrlCallback();
            OkHttpClientManager.getInstance().setVodUrlListener(callback);
            OkHttpClientManager.getInstance().getVodUrl(courseId);
        }
        if (mbIsLive) {
            mLiveRlVideoBottomC.setVisibility(View.GONE);
            mVgTop.setVisibility(View.GONE);
            mVgBottom.setVisibility(View.GONE);
            shapeLoadingDialog = new ShapeLoadingDialog.Builder(this)
                    .cancelable(true)
                    .loadText("加载中...")
                    .build();
        } else {
            mLiveRlVideoBottomC.setVisibility(View.GONE);
            mVgTop.setVisibility(View.GONE);
            mVgBottom.setVisibility(View.GONE);
            shapeLoadingDialog = new ShapeLoadingDialog.Builder(this)
                    .cancelable(false)
                    .loadText("加载中...")
                    .build();
        }

        shapeLoadingDialog.show();
        mVideoControllerTimer = new VideoControllerTimer(mVgTop, mVgBottom, mbIsLive, mLiveRlVideoBottomC);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

private void initPlayer() {
    if (!isKicout) {
        try {
            String version = ksyMediaPlayer.getVersion();
            ksyMediaPlayer.setDataSource(path);
            ksyMediaPlayer.prepareAsync();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

private void _setViewListener() {
    mSeekbar.setOnSeekBarChangeListener(this);
    mBtnBack.setOnClickListener(this);
    mBtnPlayOrPauseDemand.setOnClickListener(this);
    mLoadTv.setOnClickListener(this);
    mBackImg.setOnClickListener(this);
}

private void initRightC() {
    rightContainer = (RelativeLayout) findViewById(R.id.right_container);
    final RelativeLayout ll = (RelativeLayout) findViewById(R.id.im_container);
    ll.bringToFront();
    RelativeLayout rl = (RelativeLayout) findViewById(R.id.send_container);
    et = (EditText) findViewById(R.id.send_content_et);
    sendTv = (TextView) findViewById(R.id.send_tv);
    RelativeLayout.LayoutParams sendTvParams = (RelativeLayout.LayoutParams) sendTv.getLayoutParams();
    final ImageView image = (ImageView) findViewById(R.id.image);

    et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                try {
                    imListView.setSelection(imMessageAdapter.getCount() - 1);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }
        }
    });
    if (PadUtils.isTablet(this)) {
        image.getLayoutParams().width = ScreenUtils.getScreenWidth(this) * 49 / 1920;
        image.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 103 / 1920;
        ll.getLayoutParams().width = ScreenUtils.getScreenWidth(this) * 500 / 1920;
        rl.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 300 / 1280;
        et.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 100 / 1920;
        et.setTextSize(TypedValue.COMPLEX_UNIT_PX, ScreenUtils.getScreenWidth(this) * 32 / 1920);
        sendTv.getLayoutParams().width = ScreenUtils.getScreenWidth(this) * 100 / 1920;
        sendTv.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 60 / 1920;
        sendTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, ScreenUtils.getScreenWidth(this) * 32 / 1920);
        sendTvParams.topMargin = ScreenUtils.getScreenWidth(this) * 20 / 1920;
        sendTvParams.rightMargin = ScreenUtils.getScreenWidth(this) * 30 / 1920;
        imListView.getLayoutParams().height = ScreenUtils.getScreenHeight(this) - ScreenUtils.getScreenWidth(this) * 200 / 1920;
    } else {
        image.getLayoutParams().width = ScreenUtils.getScreenWidth(this) * 49 / 1280;
        image.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 103 / 1280;
        ll.getLayoutParams().width = ScreenUtils.getScreenWidth(this) * 500 / 1280;
        rl.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 300 / 1280;
        et.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 100 / 1280;
        et.setTextSize(TypedValue.COMPLEX_UNIT_PX, ScreenUtils.getScreenWidth(this) * 32 / 1280);
        sendTv.getLayoutParams().width = ScreenUtils.getScreenWidth(this) * 100 / 1280;
        sendTv.getLayoutParams().height = ScreenUtils.getScreenWidth(this) * 60 / 1280;
        sendTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, ScreenUtils.getScreenWidth(this) * 32 / 1280);
        sendTvParams.topMargin = ScreenUtils.getScreenWidth(this) * 20 / 1280;
        sendTvParams.rightMargin = ScreenUtils.getScreenWidth(this) * 30 / 1280;
        imListView.getLayoutParams().height = ScreenUtils.getScreenHeight(this) - ScreenUtils.getScreenWidth(this) * 200 / 1280;
    }

    //CustomScreenS_video.screenAdaptation(this,R.id.im_container,ll);
    image.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!isFoldFlag) {
                isFoldFlag = true;
                ll.setVisibility(View.VISIBLE);
                image.setBackgroundResource(R.drawable.fold_im);
            } else {
                isFoldFlag = false;
                ll.setVisibility(View.GONE);
                image.setBackgroundResource(R.drawable.unfold_im);
            }

        }
    });
    sendTv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isCanSpeak) {
                String msg = et.getText().toString();
                if (!TextUtils.isEmpty(msg)) {
                    try {
                        sendMessage(msg, et);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    });
}

private void _initView() {
    imListView = (ListView) findViewById(R.id.im_list_view);
    mRootView = (RelativeLayout) findViewById(R.id.root);
    initRightC();
    mLayout = (TextView) findViewById(R.id.layout);
    mChangeContainer = (RelativeLayout) findViewById(R.id.change_container);
    mListView = (ListView) findViewById(R.id.list_view);
    mChangeTv = (TextView) findViewById(R.id.change_tv);
    mLiveRlVideoBottomC = (RelativeLayout) findViewById(R.id.live_rl_video_controller);
    mVideoLoadingContainer = (RelativeLayout) findViewById(R.id.video_loading_c);
    mVideoDefault = (ImageView) findViewById(R.id.video_default_img);
    mBackImg = (ImageButton) findViewById(R.id.back_img);
    mVgTop = (ViewGroup) findViewById(R.id.ll_top);
    mBtnBack = (RelativeLayout) findViewById(R.id.btn_back);
    mTvTitle = (TextView) findViewById(R.id.tv_title);
    mVgBottom = (ViewGroup) findViewById(R.id.rl_video_controller);
    mBtnPlayOrPauseDemand = (ImageButton) findViewById(R.id.btn_play_pause_demand);
    mTvCurrentTime = (TextView) findViewById(R.id.tv_video_current_time);
    mTvTotalTime = (TextView) findViewById(R.id.tv_video_total_time);
    mSeekbar = (SeekBar) findViewById(R.id.seekbar_video);
    mLoadTv = (TextView) findViewById(R.id.load_tv);
    mTextHintContainer = (LinearLayout) findViewById(R.id.text_hint_container);
    bottomText = (TextView) findViewById(R.id.bottom_text);
    topText = (TextView) findViewById(R.id.top_text);
    RadiusUtils.setRadius(mLayout, Color.BLACK, 10);
    if (PadUtils.isTablet(this)) {
        bottomText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        topText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
        mLayout.getLayoutParams().width = ScreenUtils.getScreenHeight(this) * 300 / 1080;
        mLayout.getLayoutParams().height = ScreenUtils.getScreenHeight(this) * 300 / 1080;

    } else {
        bottomText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
        topText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
        mLayout.getLayoutParams().width = ScreenUtils.getScreenHeight(this) * 300 / 720;
        mLayout.getLayoutParams().height = ScreenUtils.getScreenHeight(this) * 300 / 720;
    }
    imListView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (visibleItemCount + firstVisibleItem == totalItemCount) {
                isScrollBottom = true;
            } else {
                isScrollBottom = false;
            }

        }
    });
    mChangeTv.setOnClickListener(this);
    RadiusUtils.setStroke(mChangeTv, Color.parseColor("#333333"), Color.WHITE, 1, 10);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (rtmpCurrentPosition != position) {
                rtmpCurrentPosition = position;
                path = changeList.get(position).url;
                adapter.notifyDataSetChanged();
                ksyMediaPlayer.setVideoScalingMode(KSYMediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT);
                ksyMediaPlayer.reload(path, true);
            }
            mChangeContainer.setVisibility(View.GONE);
            mVideoControllerTimer.start();
        }
    });

    mVideoSurfaceView = (SurfaceView) findViewById(R.id.video_view);
    ksyMediaPlayer = new KSYMediaPlayer.Builder(this.getApplicationContext()).build();
    ksyMediaPlayer.setOnCompletionListener(mOnCompletionListener);
    ksyMediaPlayer.setOnPreparedListener(mOnPreparedListener);
    ksyMediaPlayer.setOnInfoListener(mOnInfoListener);
    ksyMediaPlayer.setOnVideoSizeChangedListener(mOnVideoSizeChangeListener);
    ksyMediaPlayer.setOnErrorListener(mOnErrorListener);
    ksyMediaPlayer.setOnSeekCompleteListener(mOnSeekCompletedListener);
    ksyMediaPlayer.setOnBufferingUpdateListener(mOnBufferingUpdateListener);
    mSurfaceHolder = mVideoSurfaceView.getHolder();
    mSurfaceHolder.addCallback(mSurfaceCallback);

}

private void sendMessage(String msg, final EditText et) {
    // 创建文本消息
    final ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomTextMessage(
            meetingInfoData.meeting_info.roomId, // 聊天室id
            msg
    );

// 发送消息。如果需要关心发送结果,可设置回调函数。发送完成时,会收到回调。如果失败,会有具体的错误码。 NIMClient.getService(ChatRoomService.class).sendMessage(message, true).setCallback(new RequestCallback() { @Override public void onSuccess(Void aVoid) { et.setText(""); msgList.add(message); if (imMessageAdapter == null) { imMessageAdapter = new IMMessageAdapter(IJKPlayerActivity.this, msgList); imListView.setAdapter(imMessageAdapter); } else { imMessageAdapter.notifyData(msgList); } imListView.setSelection(imMessageAdapter.getCount() - 1);

        }

        @Override
        public void onFailed(int i) {

        }

        @Override
        public void onException(Throwable throwable) {

        }
    });
}

private void _initData() {
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    mScreenWidth = ScreenUtils.getScreenWidth(this);
    mScreenHeight = ScreenUtils.getScreenHeight(this);
    mGestureDetector = new GestureDetector(this, new MyGestureListener());
    mTvTitle.setText(mCourseTitle);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    try {
        if (mGestureDetector != null) {
            if (mGestureDetector.onTouchEvent(event))
                return true;
            // 处理手势结束
            switch (event.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_DOWN:
                    if (mbIsLive && mChangeContainer != null) {
                        if (mChangeContainer.getVisibility() == View.VISIBLE) {
                            if (mVideoControllerTimer != null) {
                                mVideoControllerTimer.controllerTimer(mChangeContainer);
                            }
                        }
                        mChangeContainer.setVisibility(View.GONE);
                    }
                    if (mVgTop.getVisibility() == View.GONE) {
                        if (mVideoControllerTimer != null) {
                            mVideoControllerTimer.start();
                        }
                    } else {
                        if (mVideoControllerTimer != null) {
                            mVideoControllerTimer.stop();
                        }
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    endGesture();
                    break;
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
//取消定时任务
private void stopTimer(){
    if (timer != null) {
        timer.cancel();
        timer = null;
        task.cancel();
        task = null;
    }
}
@Override
protected void onDestroy() {
    super.onDestroy();
    release();
}

private void release(){ new Thread(){ @Override public void run() { super.run(); try { isOnDestory = true; stopTimer(); if (mbIsLive) { isCanSpeak = false; NIMClient.getService(ChatRoomService.class).exitChatRoom(meetingInfoData.meeting_info.roomId); NIMClient.getService(AuthService.class).logout(); }/else{ if(isCanPalyVod){ sendPlayWatchTime= (int) ((System.currentTimeMillis()-recordPlayTime)/1000); if(sendPlayWatchTime>0) OkHttpClientManager.getInstance().sendVodData(courseId,cid,sendPlayWatchTime); } }//1分20秒/ } catch (Exception e) { e.printStackTrace(); }

           if (ksyMediaPlayer != null) {
               ksyMediaPlayer.release();
               ksyMediaPlayer = null;
           }
           Message msg = handler.obtainMessage();
           msg.arg1=000;
           handler.sendMessage(msg);
           if (thread != null) {
               thread = null;
           }
       }
   }.start();

} @Override protected void onPause() { super.onPause(); if(isCanPalyVod) { sendPlayWatchTime = (int) ((System.currentTimeMillis() - recordPlayTime) / 1000); stopTimer(); if(sendPlayWatchTime>0) OkHttpClientManager.getInstance().sendVodData(courseId,cid,sendPlayWatchTime); } }

@Override
protected void onResume() {
    super.onResume();
    try {
        if (isExit) {
            if (ksyMediaPlayer != null && ksyMediaPlayer.isPlaying()) {
                ksyMediaPlayer.stop();
                ksyMediaPlayer.release();
                ksyMediaPlayer = null;
            }
            //1分钟
            mVideoDefault.setVisibility(View.VISIBLE);
            mTextHintContainer.setVisibility(View.VISIBLE);
        } else {
            if (ksyMediaPlayer != null) {
                ksyMediaPlayer.start();
                if(isCanPalyVod){
                   recordPlayTime=System.currentTimeMillis();
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

@Override
protected void onStop() {
    super.onStop();
    if (ksyMediaPlayer != null) {
        ksyMediaPlayer.pause();
    }
}

@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.back_img:
            finish();
            break;
        case R.id.btn_back:
            finish();
            break;
        case R.id.change_tv:
            if (mChangeContainer.getVisibility() == View.VISIBLE) {
                mChangeContainer.setVisibility(View.GONE);
                mVideoControllerTimer.start();
            } else {
                mChangeContainer.setVisibility(View.VISIBLE);
                mVideoControllerTimer.controllerTimer(mChangeContainer);
            }
            break;
        case R.id.load_tv:
            mLoadTv.setVisibility(View.GONE);
            mVideoDefault.setVisibility(View.GONE);
            mTextHintContainer.setVisibility(View.GONE);
            mVideoLoadingContainer.setVisibility(View.VISIBLE);
            if (ksyMediaPlayer != null) {
                ksyMediaPlayer.setVideoScalingMode(KSYMediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT);
                ksyMediaPlayer.reload(path, true);
            }
            break;
        case R.id.btn_play_pause_demand:

            //   case R.id.btn_play_pause_live:
            mbIsPlaying = !mbIsPlaying;
            if (mbIsPlaying) {
                ksyMediaPlayer.pause();
                _updateBtnPlayPauseBg(R.drawable.video_player_pause_bg);
                if(isCanPalyVod){
                    sendPlayWatchTime= (int) ((System.currentTimeMillis()-recordPlayTime)/1000);
                    stopTimer();
                    if(sendPlayWatchTime>0)
                    OkHttpClientManager.getInstance().sendVodData(courseId,cid,sendPlayWatchTime);
                }
            } else {
                sendReport(false);
                recordPlayTime = System.currentTimeMillis();
                ksyMediaPlayer.start();
                _updateBtnPlayPauseBg(R.drawable.video_player_play_bg);
            }

            break;

    }
}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    // 通知进度已经bo修改。客户端可以使用fromUser参数区分用户触发的改变还是编程触发的改变。
    if (!fromUser)
        return;
    // TODO
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
    // 通知用户已经点播一个触摸拖动手势。客户端可能需要使用这个来禁用seekbar的滑动功能。

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    // 通知用户触摸手势已经结束。户端可能需要使用这个来启用seekbar的滑动功能。
    if (ksyMediaPlayer != null) {
        ksyMediaPlayer.seekTo(new Long(seekBar.getProgress()) * 1000);
    }

}

private void _updateBtnPlayPauseBg(int video_player_pause_bg) {
    mBtnPlayOrPauseDemand.setImageResource(video_player_pause_bg);
}

class VideoThread extends Thread {
    @Override
    public void run() {
        super.run();
        while (isReadly) {
            Message msg = handler.obtainMessage();
            msg.arg1 = 3;
            handler.sendMessage(msg);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

private ChangeAdapter adapter;
Handler handler = new Handler() {
    @Override
    public void handleMessage(final Message msg) {
        super.handleMessage(msg);
        if (mbIsLive) {
            shapeLoadingDialog.getBuilder().cancelable(true);
        }
        try {
            if (msg.arg1 == 1) {
                path = vodUrlData.play_url;
                if (TextUtils.isEmpty(path)) {
                    Toast.makeText(IJKPlayerActivity.this, "该点播无法播放", Toast.LENGTH_SHORT).show();
                    finish();
                }
                initPlayer();
            } else if(msg.arg1==000){
                if (mVideoControllerTimer != null) {
                    mVideoControllerTimer.stop();
                }
            }else if (msg.arg1 == 667) {
                dealClassPracticeData();
            } else if (msg.arg1 == 2) {
                if (!TextUtils.isEmpty(errmsg))
                    Toast.makeText(IJKPlayerActivity.this, errmsg, Toast.LENGTH_SHORT).show();
                finish();
            } else if (msg.arg1 == 3) {
                if (ksyMediaPlayer != null) {
                    mTvCurrentTime.setText(VideoUtils.formatPosition(ksyMediaPlayer.getCurrentPosition()));
                    mTvTotalTime.setText("/" + VideoUtils.formatPosition(ksyMediaPlayer.getDuration()));
                    long progress = ksyMediaPlayer.getCurrentPosition();
                    mSeekbar.setProgress(new Long(progress / 1000).intValue());
                }
            } else if (msg.arg1 == 111) {
                if(mbIsLive) {
                    OkHttpClientManager.getInstance().sendData(getJson());
                    sendReport(true);
                }else{
                    OkHttpClientManager.getInstance().sendVodData(courseId,cid,i2);
                    recordPlayTime = System.currentTimeMillis();
                    sendReport(false);
                }
            } else if (msg.arg1 == 333) {
                destoryWebView(rollCallWv);
            } else if (msg.arg1 == 444) {
                destoryWebView(questionWebView);
            } else if (msg.arg1 == 555) {
                destoryWebView(startQuizWv);
            } else if (msg.arg1 == 666) {
                destoryWebView(resultsOfQuizWv);
            } else if (msg.arg1 == 777) {
                destoryWebView(startExerciseWv);
            } else if (msg.arg1 == 5) {
                changeList = new ArrayList<>();
                for (int i = 0; i < rtmpDataList.size(); i++) {
                    for (int j = 0; j < rtmpDataList.get(i).video_format.size(); j++) {
                        String type = rtmpDataList.get(i).video_format.get(j).type;
                        String url = rtmpDataList.get(i).video_format.get(j).rtmp_play_url;
                        RtmpEntity entity = new RtmpEntity();
                        if (i == 0) {
                            if (type.equals("0") || type.equals("2")) {
                                entity.name = "线路一高清";
                                entity.url = url;
                                changeList.add(entity);
                            } else {
                                entity.name = "线路一标清";
                                entity.url = url;
                                changeList.add(entity);
                            }
                        } else if (i == 1) {
                            if (type.equals("0") || type.equals("2")) {
                                entity.name = "线路二高清";
                                entity.url = url;
                                changeList.add(entity);
                            } else {
                                entity.name = "线路二标清";
                                entity.url = url;
                                changeList.add(entity);
                            }
                        } else if (i == 2) {
                            if (type.equals("0") || type.equals("2")) {
                                entity.name = "线路三高清";
                                entity.url = url;
                                changeList.add(entity);
                            } else {
                                entity.name = "线路三标清";
                                entity.url = url;
                                changeList.add(entity);
                            }
                        } else if (i == 3) {
                            if (type.equals("0") || type.equals("2")) {
                                entity.name = "线路四高清";
                                entity.url = url;
                                changeList.add(entity);
                            } else {
                                entity.name = "线路四标清";
                                entity.url = url;
                                changeList.add(entity);
                            }
                        }
                    }
                }
                if (changeList.size() == 0) {
                    finish();
                } else {
                    path = changeList.get(0).url;
                    adapter = new ChangeAdapter();
                    mListView.setAdapter(adapter);
                    initPlayer();
                }
            } else if (msg.arg1 == 6) {
                if (!TextUtils.isEmpty(errmsg))
                    Toast.makeText(IJKPlayerActivity.this, errmsg, Toast.LENGTH_SHORT).show();
                finish();
            } else if (msg.arg1 == 7) {
                doLogin();
                Observer<List<ChatRoomMessage>> incomingChatRoomMsg = new Observer<List<ChatRoomMessage>>() {
                    @Override
                    public void onEvent(List<ChatRoomMessage> messages) {
                        for (int i = 0; i < messages.size(); i++) {
                            ChatRoomMessage msg = messages.get(i);
                            if (!TextUtils.isEmpty(msg.getContent())) {
                                msgList.add(msg);
                                if (imMessageAdapter == null) {
                                    imMessageAdapter = new IMMessageAdapter(IJKPlayerActivity.this, msgList);
                                    imListView.setAdapter(imMessageAdapter);
                                } else {
                                    imMessageAdapter.notifyData(msgList);
                                }
                                if (isScrollBottom)
                                    imListView.setSelection(imMessageAdapter.getCount() - 1);
                            }
                            if (messages.get(i).getMsgType().getValue() == 5) {
                                String json = msg.getAttachment().toString();
                                if (json.contains("isBanSpeech")) {
                                    if (json.contains("isBanSpeech=2")) {
                                        et.setHint("禁止发言");
                                        isCanSpeak = false;
                                        et.setEnabled(false);
                                        sendTv.setBackgroundColor(Color.GRAY);
                                    } else {
                                        isCanSpeak = true;
                                        et.setHint("输入内容(最多100字)");
                                        et.setEnabled(true);
                                        sendTv.setBackgroundColor(Color.parseColor("#43bbff"));
                                    }
                                }
                            }//else if(messages.get(i).getMsgType().getValue()==100){
                        }
                        //   }
                        // Toast.makeText(IJKPlayerActivity.this, messages.get(messages.size()-1).getContent(), Toast.LENGTH_SHORT).show();
                        // 处理新收到的消息
                    }
                };

                NIMClient.getService(ChatRoomServiceObserver.class)
                        .observeReceiveMessage(incomingChatRoomMsg, true);
            /*    RtmpCallback callback = new RtmpCallback();
                OkHttpClientManager.getInstance().setRtmpListener(callback);
                OkHttpClientManager.getInstance().getLiveRtmp(courseId);*/
            } else if (msg.arg1 == 8) {
                EnterChatRoomData data = new EnterChatRoomData(meetingInfoData.meeting_info.roomId);
                data.setNick(UserInfoUtils.realName);
                NIMClient.getService(ChatRoomService.class).enterChatRoom(data).setCallback(new RequestCallback() {
                    @Override
                    public void onSuccess(Object o) {
                        RtmpCallback callback = new RtmpCallback();
                        OkHttpClientManager.getInstance().setRtmpListener(callback);
                        OkHttpClientManager.getInstance().getLiveRtmp(courseId);
                    }

                    @Override
                    public void onFailed(int i) {
                        // Toast.makeText(IJKPlayerActivity.this, "onFailed", Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onException(Throwable throwable) {
                        // Toast.makeText(IJKPlayerActivity.this, "onException", Toast.LENGTH_SHORT).show();
                    }
                });

                NIMClient.getService(ChatRoomService.class).fetchRoomInfo(meetingInfoData.meeting_info.roomId).setCallback(new RequestCallback<ChatRoomInfo>() {
                    @Override
                    public void onSuccess(ChatRoomInfo chatRoomInfo) {
                        for (int i = 0; i < chatRoomInfo.getExtension().size(); i++) {
                        }
                        Set set = chatRoomInfo.getExtension().entrySet();
                        Iterator iterator = set.iterator();
                        while (iterator.hasNext()) {
                            Map.Entry mapentry = (Map.Entry) iterator.next();
                            String key = (String) mapentry.getKey();
                            String value = mapentry.getValue().toString();
                            if (key.equals("isBanSpeech") && value.equals("2")) {
                                et.setHint("禁止发言");
                                isCanSpeak = false;
                                et.setEnabled(false);
                                sendTv.setBackgroundColor(Color.GRAY);
                            }
                        }

                    }

                    @Override
                    public void onFailed(int i) {

                    }

                    @Override
                    public void onException(Throwable throwable) {

                    }
                });
            } else {
                mLayout.setVisibility(View.GONE);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
};

private void dealClassPracticeData() {
    try {
        switch (classPracticeData.type) {
            case "startRollcall":
                destoryWebView(rollCallWv);//为了防止出现多个点名界面,所以先判断下之前的点名界面是否存在,存在则销毁掉
                rollCallWv = new WebView(this);
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
                mRootView.addView(rollCallWv, params);
                rollCallWv.getSettings().setDomStorageEnabled(true);
                rollCallWv.setBackgroundColor(Color.TRANSPARENT);
                rollCallWv.addJavascriptInterface(new JSCallback(), "JSCallback");
                rollCallWv.getSettings().setJavaScriptEnabled(true);
                rollCallWv.loadUrl(classPracticeData.data + "&userName=" + UserInfoUtils.userLogin);
                break;
            case "closeRollcall":
                destoryWebView(rollCallWv);
                break;
            case "startQuiz":
                destoryWebView(startQuizWv);
                startQuizWv = new WebView(this);
                RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
                mRootView.addView(startQuizWv, params2);
                startQuizWv.bringToFront();
                startQuizWv.getSettings().setDomStorageEnabled(true);
                startQuizWv.setBackgroundColor(Color.TRANSPARENT);
                startQuizWv.addJavascriptInterface(new JSCallback(), "JSCallback");
                startQuizWv.getSettings().setJavaScriptEnabled(true);
                startQuizWv.loadUrl(classPracticeData.data + "&userName=" + UserInfoUtils.userLogin);
                break;
            case "closeQuiz":
                destoryWebView(startQuizWv);
                destoryWebView(resultsOfQuizWv);
                break;
            case "startQuestionnaire":
                destoryWebView(questionWebView);
                questionWebView = new WebView(this);
                RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
                mRootView.addView(questionWebView, params1);
                questionWebView.setBackgroundColor(Color.TRANSPARENT);
                questionWebView.getSettings().setDomStorageEnabled(true);
                questionWebView.addJavascriptInterface(new JSCallback(), "JSCallback");
                questionWebView.getSettings().setJavaScriptEnabled(true);
                questionWebView.loadUrl(classPracticeData.data + "&userName=" + UserInfoUtils.userLogin);
                break;
            case "resultsOfQuiz":
                destoryWebView(startQuizWv);
                destoryWebView(resultsOfQuizWv);
                resultsOfQuizWv = new WebView(this);
                RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
                mRootView.addView(resultsOfQuizWv, params3);
                resultsOfQuizWv.getSettings().setDomStorageEnabled(true);
                resultsOfQuizWv.setBackgroundColor(Color.TRANSPARENT);
                resultsOfQuizWv.addJavascriptInterface(new JSCallback(), "JSCallback");
                resultsOfQuizWv.getSettings().setJavaScriptEnabled(true);
                //  resultsOfQuizWv.loadUrl("http://k12.techbridge-inc.com:8099/index.php?&m=ClassroomTest&a=answerTest&subId=1&type=256");
                resultsOfQuizWv.loadUrl(classPracticeData.data + "&userName=" + UserInfoUtils.userLogin);
                break;
            case "closeQuestionnaire":
                destoryWebView(questionWebView);
                break;
            case "startExercise":
                destoryWebView(startExerciseWv);
                startExerciseWv = new WebView(this);
                RelativeLayout.LayoutParams params4 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
                mRootView.addView(startExerciseWv, params4);
                startExerciseWv.getSettings().setDomStorageEnabled(true);
                startExerciseWv.setBackgroundColor(Color.TRANSPARENT);
                startExerciseWv.addJavascriptInterface(new JSCallback(), "JSCallback");
                startExerciseWv.getSettings().setJavaScriptEnabled(true);
                startExerciseWv.loadUrl(classPracticeData.data + "&user_name=" + UserInfoUtils.userLogin);
                startExerciseWv.setWebViewClient(new WebViewClient() {
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        return false;
                    }
                });
                startExerciseWv.setOnLongClickListener(new View.OnLongClickListener() {
                    @Override
                    public boolean onLongClick(View v) {
                        return false;
                    }
                });
                break;
            case "stopExercise":
                if (startExerciseWv != null) {
                    startExerciseWv.loadUrl("javascript:submitStudLessonTestAnswer()");
                }
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

private void destoryWebView(WebView webView) {
    if (webView != null) {
        mRootView.removeView(webView);
        webView.clearHistory();
        webView.clearCache(true);
        webView = null;
    }

}

public class JSCallback {
    @JavascriptInterface
    public void closeQuestionnaire() { //结束问卷调查
        Message msg = handler.obtainMessage();
        msg.arg1 = 444;
        handler.sendMessage(msg);

    }

    @JavascriptInterface
    public void closeRollCall() { //结束点名
        Message msg = handler.obtainMessage();
        msg.arg1 = 333;
        handler.sendMessage(msg);
    }

    @JavascriptInterface
    public void closeQuiz() { //关闭随堂测
        Message msg = handler.obtainMessage();
        msg.arg1 = 555;
        handler.sendMessage(msg);

    }

    @JavascriptInterface
    public void closeResultOfQuiz() { //关闭随堂测结果
        Message msg = handler.obtainMessage();
        msg.arg1 = 666;
        handler.sendMessage(msg);
    }

    @JavascriptInterface
    public void closeExercise() { //关闭随堂测结果
        Message msg = handler.obtainMessage();
        msg.arg1 = 777;
        handler.sendMessage(msg);
    }
}

class ChangeAdapter extends BaseAdapter {

    @Override
    public int getCount() {
        return changeList.size();
    }

    @Override
    public Object getItem(int position) {
        return changeList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View view = null;
        TextView tv = null;
        if (view == null) {
            view = LayoutInflater.from(IJKPlayerActivity.this).inflate(R.layout.change_list_item, null);
            tv = (TextView) view.findViewById(R.id.tv);
        }
        tv.setText(changeList.get(position).name);
        if (position == rtmpCurrentPosition) {
            tv.setTextColor(Color.parseColor("#43bbff"));
        } else {
            tv.setTextColor(Color.WHITE);
        }
        map.put(position, tv);
        return view;
    }
}

class RtmpCallback implements RtmpListener {

    @Override
    public void reqSuccess(int type, Object oj) {
        if (type == -2) {
            meetingInfoData = (MeetingInfoBean.Data) oj;
            Message msg = handler.obtainMessage();
            msg.arg1 = 7;
            handler.sendMessage(msg);
        } else {
            rtmpDataList = (List<RtmpBean.Data>) oj;
            Message msg = handler.obtainMessage();
            msg.arg1 = 5;
            handler.sendMessage(msg);
        }
    }

    @Override
    public void reqFailed(int type, Object error) {
        if (type == -2) {

        } else {
            errmsg = (String) error;
            Message msg = handler.obtainMessage();
            msg.arg1 = 6;
            handler.sendMessage(msg);
        }
    }
}

class VodUrlCallback implements VodUrlListener {

    @Override
    public void reqSuccess(int type, Object oj) {
        vodUrlData = (VodUrlBean.Data) oj;
        Message msg = handler.obtainMessage();
        msg.arg1 = 1;
        handler.sendMessage(msg);
    }

    @Override
    public void reqFailed(int type, Object error) {
        errmsg = (String) error;
        Message msg = handler.obtainMessage();
        msg.arg1 = 2;
        handler.sendMessage(msg);
    }
}

class RtmpEntity {
    public String name;
    public String url;
}

private void endGesture() {
    mVolume = -1;
    mBrightness = -1;
    if (mSeekFlag && !mbIsLive && ksyMediaPlayer != null) {
        ksyMediaPlayer.seekTo(currentPosition);
    }
    mSeekFlag = false;
    mBrightFlag = false;
    mSoundFlag = false;
    // 隐藏
    Message msg = handler.obtainMessage();
    msg.arg1 = 33;
    handler.sendMessage(msg);

}

private class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {

        float oldX = e1.getX(), oldY = e1.getY();
        int y = (int) e2.getRawY();
        int x = (int) e2.getRawX();
        if (!mSeekFlag && !mBrightFlag && !mSoundFlag) {
            if ((Math.abs(distanceX)) > Math.abs(distanceY)) {
                mSeekFlag = true;
                //  mLayout.setVisibility(View.VISIBLE);
            } else if (oldX > mScreenWidth * 1.0 / 2) {
                mSoundFlag = true;
                //    onVolumeSlide((oldY - y) / mScreenHeight);
            } else if (oldX < mScreenWidth * 1.0 / 2) {
                mBrightFlag = true;
                //     onBrightnessSlide((oldY - y) / mScreenHeight);
            }
        }
        if (mSeekFlag) {
            onSeekTo((x - oldX) / mScreenWidth);
        } else if (mBrightFlag) {
            onBrightnessSlide((oldY - y) / mScreenHeight);
        } else if (mSoundFlag) {
            onVolumeSlide((oldY - y) / mScreenHeight);
        }
        return super.onScroll(e1, e2, distanceX, distanceY);
    }
}

private void onSeekTo(float percent) {
    //    if(mVideoViewPresent!=null&&mVideoViewPresent.isVideoPlay()){
    if (!mbIsLive && isRtmpNormal) {
        mLayout.setVisibility(View.VISIBLE);
        currentPosition = (long) (ksyMediaPlayer.getCurrentPosition() + percent * ksyMediaPlayer.getDuration());
        if (currentPosition < 0) {
            currentPosition = 0;
        } else if (currentPosition > ksyMediaPlayer.getDuration()) {
            currentPosition = ksyMediaPlayer.getDuration();
        }
        mLayout.setText("进度:" + VideoUtils.formatPosition(currentPosition));
    }
    //   }
}

private void onVolumeSlide(float percent) {
    if (mVolume == -1) {
        mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
        if (mVolume < 0)
            mVolume = 0;
        mLayout.setVisibility(View.VISIBLE);
    }
    int index = (int) (percent * mMaxVolume) + mVolume;
    if (index > mMaxVolume)
        index = mMaxVolume;
    else if (index < 0)
        index = 0;
    // 变更声音
    int progress = Math.round(index * 100 / mMaxVolume);
    mLayout.setText("声音:" + progress + "%");
    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
}

private void onBrightnessSlide(float percent) {
    if (mBrightness < 0) {
        mBrightness = getWindow().getAttributes().screenBrightness;
        if (mBrightness <= 0.00f)
            mBrightness = 0.50f;
        if (mBrightness < 0.01f)
            mBrightness = 0.01f;
        mLayout.setVisibility(View.VISIBLE);
    }
    WindowManager.LayoutParams lpa = getWindow().getAttributes();
    lpa.screenBrightness = mBrightness + percent;
    if (lpa.screenBrightness > 1.0f)
        lpa.screenBrightness = 1.0f;
    else if (lpa.screenBrightness < 0.01f)
        lpa.screenBrightness = 0.01f;
    getWindow().setAttributes(lpa);
    int progress = Math.round(lpa.screenBrightness * 100);
    mLayout.setText("亮度:" + progress + "%");
}

private final SurfaceHolder.Callback mSurfaceCallback = new SurfaceHolder.Callback() {
    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        if (ksyMediaPlayer != null) {
            ksyMediaPlayer.setDisplay(holder);
            ksyMediaPlayer.setScreenOnWhilePlaying(true);
        }
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        // 此处非常重要,必须调用!!!
        if (ksyMediaPlayer != null) {
            ksyMediaPlayer.setDisplay(null);
        }
    }
};
private IMediaPlayer.OnPreparedListener mOnPreparedListener = new IMediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(IMediaPlayer mp) {
        shapeLoadingDialog.dismiss();
         if(!(mTextHintContainer.getVisibility()==View.VISIBLE&&topText.getText().toString().equals("其他用户使用了相同的"))) {
            isRtmpNormal = true;
            mLoadTv.setVisibility(View.GONE);
            mVideoLoadingContainer.setVisibility(View.GONE);
            //mProgressContainer.setVisibility(View.GONE);
            if (mVideoDefault.getVisibility() == View.VISIBLE) {
                mVideoDefault.setVisibility(View.GONE);
                mTextHintContainer.setVisibility(View.GONE);
            }
            try {
                if (!mbIsLive) {
                    shapeLoadingDialog.getBuilder().cancelable(true);
                    ksyMediaPlayer.setLooping(true);
                }
                // 设置视频伸缩模式,此模式为裁剪模式
                ksyMediaPlayer.setVideoScalingMode(KSYMediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT);
                // 开始播放视频
                ksyMediaPlayer.start();
                startTime = System.currentTimeMillis();
                mSeekbar.setMax(new Long(ksyMediaPlayer.getDuration() / 1000).intValue());
                if (thread == null && !mbIsLive) {
                    thread = new VideoThread();
                    thread.start();
                }
                if (mbIsLive) {
                    isSendReport = true;
                    sendReport(true);
                } else {
                    OkHttpClientManager.getInstance().sendVodData(courseId,cid,0);
                    sendReport(false);
                    isCanPalyVod = true;
                    recordPlayTime = System.currentTimeMillis();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
};

//和云信建立连接
public void doLogin() {
    loginWx();
}
private void register(){
    //获取自定义消息的通知
    CustomAttachParser cap = new CustomAttachParser();
    cap.setClassPracticeListener(new ClassPracticeCallback());
    NIMClient.getService(MsgService.class).registerCustomAttachmentParser(cap);

    Observer<ChatRoomKickOutEvent> kickOutObserver = new Observer<ChatRoomKickOutEvent>() {
        @Override
        public void onEvent(ChatRoomKickOutEvent chatRoomKickOutEvent) {
            isExit = true;
            mChangeContainer.setVisibility(View.GONE);
            isKicout = true;
            if (ksyMediaPlayer != null && ksyMediaPlayer.isPlaying()) {
                ksyMediaPlayer.stop();
                ksyMediaPlayer.release();
                ksyMediaPlayer = null;
            }
            try {
                if (shapeLoadingDialog != null && shapeLoadingDialog.isShowing()) {
                    shapeLoadingDialog.dismiss();
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            mVideoDefault.setVisibility(View.VISIBLE);
            mTextHintContainer.setVisibility(View.VISIBLE);
            KeyBoardUtils.closeKeyboard(IJKPlayerActivity.this, et);
            rightContainer.setVisibility(View.GONE);
            mLoadTv.setVisibility(View.GONE);
            mChangeTv.setVisibility(View.GONE);
            topText.setText("其他用户使用了相同的");
            bottomText.setText("账号加入了课堂!");
            isCanSpeak = false;
            exitAllWebView();
            // Toast.makeText(IJKPlayerActivity.this, "被踢出", Toast.LENGTH_SHORT).show();
            // 提示被踢出的原因(聊天室已解散、被管理员踢出、被其他端踢出等)
            // 清空缓存数据
        }
    };

    NIMClient.getService(ChatRoomServiceObserver.class)
            .observeKickOutEvent(kickOutObserver, true);

    NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus(
            new Observer<StatusCode>() {
                public void onEvent(StatusCode status) {
                    if (status.wontAutoLogin()) {
                        isSendReport = false;
                        if (status.getValue() == 7) {
                            isExit = true;
                            isKicout = true;
                            mChangeContainer.setVisibility(View.GONE);
                            try {
                                if (shapeLoadingDialog != null && shapeLoadingDialog.isShowing()) {
                                    shapeLoadingDialog.dismiss();
                                }
                            }catch (Exception e){
                                e.printStackTrace();
                            }

                            if (ksyMediaPlayer != null && ksyMediaPlayer.isPlaying()) {
                                ksyMediaPlayer.stop();
                                ksyMediaPlayer.release();
                                ksyMediaPlayer = null;
                            }
                            mVideoDefault.setVisibility(View.VISIBLE);
                            mTextHintContainer.setVisibility(View.VISIBLE);
                            KeyBoardUtils.closeKeyboard(IJKPlayerActivity.this, et);
                            rightContainer.setVisibility(View.GONE);
                            mLoadTv.setVisibility(View.GONE);
                            mChangeTv.setVisibility(View.GONE);
                            topText.setText("其他用户使用了相同的");
                            bottomText.setText("账号加入了课堂!");
                            isCanSpeak = false;
                            // Toast.makeText(IJKPlayerActivity.this, "被踢出", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(IJKPlayerActivity.this, "请检查网络或服务器连接异常", Toast.LENGTH_SHORT).show();
                        }
                        exitAllWebView();
                    }
                }
            }, true);
}
//和云信建立连接
private void loginWx() {
    try {
        LoginInfo info = new LoginInfo(meetingInfoData.meeting_info.uid, meetingInfoData.meeting_info.sdktoken, meetingInfoData.meeting_info.appKey);
        RequestCallback<LoginInfo> callback =
                new RequestCallback<LoginInfo>() {
                    @Override
                    public void onSuccess(LoginInfo loginInfo) {
                        register();
                        Message msg = handler.obtainMessage();
                        msg.arg1 = 8;
                        handler.sendMessage(msg);
                    }

                    @Override
                    public void onFailed(int i) {
                        //  Toast.makeText(IJKPlayerActivity.this, "登录失败", Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onException(Throwable throwable) {
                        // Toast.makeText(IJKPlayerActivity.this, "登录失败", Toast.LENGTH_SHORT).show();
                    }
                    // 可以在此保存LoginInfo到本地,下次启动APP做自动登录用
                };
        NIMClient.getService(AuthService.class).login(info).setCallback(callback);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

class ClassPracticeCallback implements ClassPracticeListener {

    @Override
    public void reqSuccess(Object oj) {
        classPracticeData = (ClassPracticeBean) oj;
        Message msg = handler.obtainMessage();
        msg.arg1 = 667;
        handler.sendMessage(msg);
    }
}

private IMediaPlayer.OnCompletionListener mOnCompletionListener = new IMediaPlayer.OnCompletionListener() {
    @Override
    public void onCompletion(IMediaPlayer iMediaPlayer) {

    }
};

private void exitAllWebView() {
    destoryWebView(resultsOfQuizWv);
    destoryWebView(rollCallWv);
    destoryWebView(questionWebView);
    destoryWebView(startQuizWv);
    destoryWebView(startExerciseWv);
}
private void sendReport(boolean isLive) {
    if (!isOnDestory) {
        Random random = new Random();
        if (isLive) {
            i2 = random.nextInt(60) + 60;
        } else {
            i2 = 60*10;
        }
        if (timer != null) {
            timer.cancel();
            timer = null;
            task.cancel();
            task = null;
        }
        timer = new Timer();
        task = new ReportTimerTask();
        timer.schedule(task, i2 * 1000);
    } else {
        if (timer != null) {
            timer.cancel();
            timer = null;
            task.cancel();
            task = null;
        }
    }
}

class ReportTimerTask extends TimerTask {

    @Override
    public void run() {
        Message msg = handler.obtainMessage();
        msg.arg1 = 111;
        handler.sendMessage(msg);

    }
}

private IMediaPlayer.OnErrorListener mOnErrorListener = new IMediaPlayer.OnErrorListener() {
    @Override
    public boolean onError(IMediaPlayer iMediaPlayer, int i, int i1) {
        //     Log.i("Activity","mOnCompletionListener"+"");
        //mProgressContainer.setVisibility(View.GONE);
        try {

            if (shapeLoadingDialog.isShowing())
                shapeLoadingDialog.dismiss();
            if (mbIsLive) {
                mVideoDefault.setVisibility(View.VISIBLE);
                mTextHintContainer.setVisibility(View.VISIBLE);
                mVideoLoadingContainer.setVisibility(View.GONE);
                if (!isExit)
                    mLoadTv.setVisibility(View.VISIBLE);
                isSendReport = false;
          /*  if(timer!=null){
                timer.cancel();
                timer=null;
            }*/
                //  exitAllWebView();
            }else{
                if(isCanPalyVod){
                    isCanPalyVod=false;
                    sendPlayWatchTime= (int) ((System.currentTimeMillis()-recordPlayTime)/1000);
                    stopTimer();
                    if(sendPlayWatchTime>0)
                        OkHttpClientManager.getInstance().sendVodData(courseId,cid,sendPlayWatchTime);
                }
                if (timer != null) {
                    timer.cancel();
                    timer = null;
                    task.cancel();
                    task = null;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return false;
    }
};
private IMediaPlayer.OnInfoListener mOnInfoListener = new IMediaPlayer.OnInfoListener() {
    @Override
    public boolean onInfo(IMediaPlayer iMediaPlayer, int i, int i1) {
        switch (i) {
            case KSYMediaPlayer.MEDIA_INFO_BUFFERING_START:
                if (!shapeLoadingDialog.isShowing())
                    shapeLoadingDialog.show();
                //mProgressContainer.setVisibility(View.VISIBLE);
                break;
            case KSYMediaPlayer.MEDIA_INFO_BUFFERING_END:
                if (shapeLoadingDialog.isShowing())
                    shapeLoadingDialog.dismiss();
                //    mProgressContainer.setVisibility(View.GONE);
                break;
            case KSYMediaPlayer.MEDIA_INFO_SUGGEST_RELOAD:
                // 播放SDK有做快速开播的优化,在流的音视频数据交织并不好时,可能只找到某一个流的信息
                // 当播放器读到另一个流的数据时会发出此消息通知
                // 请务必调用reload接口
                if (ksyMediaPlayer != null)
                    ksyMediaPlayer.reload(path, false);
                break;
            case KSYMediaPlayer.MEDIA_INFO_RELOADED:
                mLoadTv.setVisibility(View.GONE);
                mVideoLoadingContainer.setVisibility(View.GONE);
                shapeLoadingDialog.dismiss();
                //    mProgressContainer.setVisibility(View.GONE);
                if (mVideoDefault.getVisibility() == View.VISIBLE) {
                    mVideoDefault.setVisibility(View.GONE);
                    mTextHintContainer.setVisibility(View.GONE);
                }
                break;
        }
        return false;
    }
};
private IMediaPlayer.OnSeekCompleteListener mOnSeekCompletedListener = new IMediaPlayer.OnSeekCompleteListener() {
    @Override
    public void onSeekComplete(IMediaPlayer iMediaPlayer) {
    }
};
private IMediaPlayer.OnVideoSizeChangedListener mOnVideoSizeChangeListener = new IMediaPlayer.OnVideoSizeChangedListener() {
    @Override
    public void onVideoSizeChanged(IMediaPlayer iMediaPlayer, int i, int i1, int i2, int i3) {
    }
};
private IMediaPlayer.OnBufferingUpdateListener mOnBufferingUpdateListener = new IMediaPlayer.OnBufferingUpdateListener() {
    @Override
    public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int i) {
    }
};

private String getJson() {
    String jsonresult = "";//定义返回字符串
    try {
        JSONObject jsonObj = new JSONObject();
        jsonObj.put("type", "updateOnlineTime");
        jsonObj.put("meetingId", meetingInfoData.meeting_info.meetingId);
        jsonObj.put("userName", UserInfoUtils.userLogin);
        jsonObj.put("onlineTime", i2);
        jsonObj.put("clientType", 5);
        jsonObj.put("timestamp", System.currentTimeMillis() / 1000);
        // 把每个数据当作一对象添加到数组里
        jsonresult = jsonObj.toString();//生成返回字符串
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }
    //Log.i("生成的json串为:",i2+"---"+System.currentTimeMillis()/1000);

    return jsonresult;
}

private AudioManager mAudioManager;
/**
 *  最大声音 
 */
private int mMaxVolume;
/**
 *  当前声音 
 */
private int mVolume = -1;
/**
 *  当前亮度 
 */
private float mBrightness = -1f;
private GestureDetector mGestureDetector;
private int mScreenWidth;
private int mScreenHeight;
private TextView mLayout;
private boolean mSeekFlag = false;
private boolean mBrightFlag = false;
private boolean mSoundFlag = false;
private long currentPosition;
// 播放器的对象
private KSYMediaPlayer ksyMediaPlayer;
// 播放SDK提供的监听器
// 播放器在准备完成,可以开播时会发出onPrepared回调
// 播放完成时会发出onCompletion回调
// 播放器遇到错误时会发出onError回调
private SurfaceView mVideoSurfaceView;
private SurfaceHolder mSurfaceHolder;
private List<ChatRoomMessage> msgList = new ArrayList<>();
private IMMessageAdapter imMessageAdapter;
private String json;
private ClassPracticeBean classPracticeData;

}

FirmianaRain commented 6 years ago

播放器报错之后,内部就不会再读取数据,等待使用者退出播放器或者发起重连,从代码来看没看出哪有出现崩溃的可能