How do video players like netflix or google handle show/hide video player control?

Viewed 386

I am working on a small project for my own use and I need my accessibility service to perform a tap on the screen and show/hide the controls from video players such as Netflix or youtube.

So in my accessibilityService I use getRootInActiveWindow() and I get reference to the app window (com.netflix.mediaclient for example)

I then traverse through all the nodes and I do performAction(AccessibilityNodeInfo.ACTION_CLICK) but it seems none of the nodes are clickable (when the media player control is hidden, otherwise I can click on control buttons) and I can`t make the media player control to show up.

Any idea why this might be the case? Also, is it possible to perform a tap on the screen in general and not on a specific AccessibilityNodeInfo?

UPDATE

It turned out the issue was that ACTION_CLICK does not work as a TOUCH so if the view reacts to touch events but not to click events then ACTION_CLICK will not do anything. Unfortunately, it seems like there is no way to perform tap on AccessibilityNodeInfo objects.

1 Answers

I was unable to make the video player control to appear through accessibility nodes but I was able to achieve a similar effect by just mimicking a tap on a screen with following code.

private void click(int x, int y) {
    Path path = new Path();
    path.moveTo(x, y);
    path.moveTo(x+10, y+10);
    GestureDescription.Builder builder = new GestureDescription.Builder();
    GestureDescription gestureDescription = builder.addStroke(new GestureDescription.StrokeDescription(path, 10, 200)).build();
    dispatchGesture(gestureDescription, null, null);
}

And then I call the click function with something like 300, 300

Make sure to put

android:canPerformGestures="true"

in your AccessibilityService XML file.

I am still curious why I was not able to achieve the same with nodes though so please let me know if anyone is aware.

Related