Genymobile / genymotion-device-web-player

Genymotion Virtual Device Web Player
https://www.genymotion.com/
MIT License
90 stars 31 forks source link

Rotation #83

Open GregoryNative opened 2 months ago

GregoryNative commented 2 months ago

Prerequisites

Description

I want to start emulator rotated to landscape mode. Looks like its not possible right now. But maybe I can programmatically rotate it once web player is loaded? Same way as user click on rotate button. Is it possible?

pgivel commented 1 month ago

Hi :) I'm assuming you're using this specific repo and not one of products that are more consumer-ready like Genymotion SaaS or Genymotion Device Image, and that you are using version 3.x. If that's not the case, then some names will not be the same, but the logic stays.

At device renderer creation, you can keep a reference to the instance:

auto renderer = deviceRendererFactory.setupRenderer();

Then you can send an event like this in order to rotate the emulator:

renderer.sendEvent({type: 'ROTATE'});

Warning though: in the next release, the factory will not return the instance directly, but rather a generated API. We'll probably add a simple call in order to do this, but anyway you'll still be able to access the instance like this:

auto rendererAPI = deviceRendererFactory.setupRenderer();
rendererAPI.instance.sendEvent({type: 'ROTATE'});

Hope that helps!