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
853 stars 246 forks source link

在6.0以上的系统滑动调节亮度会挂。 #211

Open weigecode opened 6 years ago

weigecode commented 6 years ago

在6.0以上的系统滑动调节亮度会挂,这是为什么?

FirmianaRain commented 6 years ago

机型跟系统版本是?

weigecode commented 6 years ago

@FirmianaRain 小米6 7.1的系统。还有华为荣耀8, 6.0的系统。

FirmianaRain commented 6 years ago

@weigecode 我们这边测试下

FirmianaRain commented 6 years ago

@weigecode 我们这边用小米6 7.1.1测试,没有出现崩溃

weigecode commented 6 years ago

@FirmianaRain 有没有动态申请权限呢?

weigecode commented 6 years ago

@FirmianaRain 我后面加了申请权限就可以了!

FirmianaRain commented 6 years ago

动态申请了什么权限?

weigecode commented 6 years ago

@FirmianaRain 这是通过设置系统来改变亮度,需要请求权限: // 根据当前进度改变亮度 6.0以上需要申请权限 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!Settings.System.canWrite(context)) { Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS); intent.setData(Uri.parse("package:" + context.getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } else { //有了权限,具体的动作 Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, tmpInt); } }

也可以直接给窗口设置,这样好像不需要请求权限了: // 根据亮度值修改当前window亮度 public void changeAppBrightness(Context context, int brightness) { Window window = getAppCompActivity(context).getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); if (brightness == -1) { lp.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; } else { lp.screenBrightness = (brightness <= 0 ? 1 : brightness) / 255f; } getAppCompActivity(context).getWindow().setAttributes(lp); }

FirmianaRain commented 6 years ago

可以看下demo里的com.ksyun.player.now.utils.Displayer这个类以及使用它的地方