Поворот Android экрана непрерывно с поворотом телефона - PullRequest
0 голосов
/ 09 июля 2020

Я пытаюсь создать приложение, в котором я проигрываю видео с помощью exoplayer. Теперь я пытаюсь добиться, чтобы при повороте телефона под любым углом видео также вращалось под таким же углом. см. этот клип для получения дополнительных разъяснений - https://www.youtube.com/watch?v=Dufuj-GnRiQ Я пытаюсь сделать это с помощью методов RotationX и RotationY. Я не знаю, как этого добиться. Пожалуйста, помогите кто-нибудь. Я использую датчик ориентации.

SensorEventListener sensorEventListener=new SensorEventListener() {
    @Override
    public void onSensorChanged(SensorEvent event) {
        Toast.makeText(MainActivity.this,"triggered!",Toast.LENGTH_SHORT).show();
       //playerView.getVideoSurfaceView().setRotationY(event.values[1]);
      //playerView.getVideoSurfaceView().setRotationY(event.values[2]);
      //playerView.getVideoSurfaceView().setZ(event.values[3]);
       //playerView.setZ(event.values[0]);
        //playerView.setRotationY(event.values[2]);
        //playerView.setRotationX(event.values[1]);
        //Toast.makeText(MainActivity.this,"x:"+event.values[1],Toast.LENGTH_SHORT).show();
        //Toast.makeText(MainActivity.this,"y:"+event.values[2],Toast.LENGTH_SHORT).show();
        //Toast.makeText(MainActivity.this,"z:"+event.values[0],Toast.LENGTH_SHORT).show();
       // playerView.getVideoSurfaceView().setRotation(display.getRotation());
        //playerView.getVideoSurfaceView().setRotation(SensorManager.getInclination(event.values))
        LinearLayout linearLayout=(LinearLayout)findViewById(R.id.linear_layout);

      // player.setRotationX(event.values[2]);

        SurfaceView surfaceView= (SurfaceView) playerView.getVideoSurfaceView();
        linearLayout.setRotationX(event.values[2]);
        linearLayout.setTranslationX(event.values[2]);
        linearLayout.setRotationY(event.values[1]);
        linearLayout.setRotationY(event.values[1]);
        surfaceView.setRotationX(event.values[2]);
        surfaceView.setTranslationX(event.values[2]);
        surfaceView.setRotationY(event.values[1]);
        surfaceView.setTranslationY(event.values[1]);
        player.setVideoSurfaceView(surfaceView);
       // linearLayout.setRotationY(event.values[1]);
        //playerView.get().setRotationX(event.values[0]);
        //playerView.getOverlayFrameLayout().setRotationY(event.values[1]);

    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {

    }
};
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...