Player_Android icon indicating copy to clipboard operation
Player_Android copied to clipboard

【Android】 - 【8.2.9808】- 【每第一次手势开音量的时候,都会先飙升到最大】

Open FunTc opened this issue 5 years ago • 5 comments

【当前现象】:运行此demo,每次进入播放页面,第一次使用手势来调节音量的时候都会先飙升到最大值; 【机型】:HUAWEI Mate 9 【bug来源】:在VideoGestureDetector中的check方法的VOLUME分支中,height为0时,newVolume会飙升到一个很大的值, 【建议修改】:

public void check(int height, MotionEvent downEvent, MotionEvent moveEvent, float distanceX, float distanceY) {
        
        ...

            case VOLUME:
                int value = height / mMaxVolume;
                int newVolume = (int) ((downEvent.getY() - moveEvent.getY()) / value * mSensitivity + mOldVolume);
                mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, newVolume, AudioManager.FLAG_PLAY_SOUND);

                float volumeProgress = newVolume / Float.valueOf(mMaxVolume) * 100;
                if (mVideoGestureListener != null) {
                    mVideoGestureListener.onVolumeGesture(volumeProgress);
                }
                break;

       ...

    }

为:

public void check(int height, MotionEvent downEvent, MotionEvent moveEvent, float distanceX, float distanceY) {
        
        ...

            case VOLUME:
                int value = height / mMaxVolume;
                float newVolume = value == 0 ? 0 : (downEvent.getY() - moveEvent.getY()) / value * mSensitivity;
                newVolume += mOldVolume;
                mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int) newVolume, AudioManager.FLAG_PLAY_SOUND);
                float volumeProgress = newVolume / mMaxVolume * 100;
                if (mVideoGestureListener != null) {
                    mVideoGestureListener.onVolumeGesture(volumeProgress);
                }
                break;

        ...

    }

FunTc avatar Dec 29 '20 07:12 FunTc

您好,根据您的描述可以拍个视频复现下 技术问题,欢迎交流 Q2562367495 注明来意

Tencent-Alice avatar Jan 07 '21 08:01 Tencent-Alice

您好,根据您的描述可以拍个视频复现下 技术问题,欢迎交流 Q2562367495 注明来意

Demo运行起来就能看到了,或者打个log,或者调试我所说的地方

FunTc avatar Jan 07 '21 08:01 FunTc

这个可以自己修改,demo只是提供了基本的用法

zzzsssbo avatar Jan 11 '21 03:01 zzzsssbo

这个可以自己修改,demo只是提供了基本的用法

我说的是superplayerkit里面的bug,而不是demo的使用。这个的使用是导入此module,当然可以自己修改,但这也算是提供的 一个扩展库,库中有bug,维护者不应该改下吗?

FunTc avatar Jan 11 '21 06:01 FunTc

@FunTc 将 int value = height / mMaxVolume; 改成 int value = height / Float.valueOf(mMaxVolume);就行了

LxzBUG avatar Nov 16 '21 07:11 LxzBUG