Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix channel "dispatchMediaKeyEvent" error #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yellowfisherz
Copy link

When I used the dispatchMediaKeyEvent method of AndroidAudioManager, an error occurred. Upon reviewing the source code, I found that the key value in the Map did not match, so I made a modification.

error key : code, repeat, scancode

original code

Map<String, dynamic> _toMap() => <String, dynamic>{
        'deviceId': deviceId,
        'source': source,
        'displayId': displayId,
        'metaState': metaState,
        'action': action,
        'keyCode': keyCode,
        'scanCode': scanCode,
        'repeatCount': repeatCount,
        'flags': flags,
        'downTime': downTime,
        'eventTime': eventTime,
      };
 private Object dispatchMediaKeyEvent(Map<?, ?> rawKeyEvent) {
            requireApi(19);
            KeyEvent keyEvent = new KeyEvent(
                    getLong(rawKeyEvent.get("downTime")),
                    getLong(rawKeyEvent.get("eventTime")),
                    (Integer)rawKeyEvent.get("action"),
                    (Integer)rawKeyEvent.get("code"),
                    (Integer)rawKeyEvent.get("repeat"),
                    (Integer)rawKeyEvent.get("metaState"),
                    (Integer)rawKeyEvent.get("deviceId"),
                    (Integer)rawKeyEvent.get("scancode"),
                    (Integer)rawKeyEvent.get("flags"),
                    (Integer)rawKeyEvent.get("source"));
            audioManager.dispatchMediaKeyEvent(keyEvent);
            return null;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant