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

Orientation #510

Closed
HHQuraishi opened this issue Aug 22, 2023 · 6 comments
Closed

Orientation #510

HHQuraishi opened this issue Aug 22, 2023 · 6 comments

Comments

@HHQuraishi
Copy link

The videos play only in portrait mode.
Even if the auto rotate is turned on the orientation does not change.

@Gauravkumar1502
Copy link

What if we consider using the following code snippet?

Auto Rotate

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        // Portrait orientation
        // Add your code here to handle portrait mode
    } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        // Landscape orientation
        // Add your code here to handle landscape mode
    }
}

Rotate Based on click

// Assuming you have a button with the ID "toggleOrientationButton"
Button toggleOrientationButton = findViewById(R.id.toggleOrientationButton);

toggleOrientationButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        int currentOrientation = getResources().getConfiguration().orientation;
        if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }
});

@HHQuraishi
Copy link
Author

Yes we can try

@Gauravkumar1502
Copy link

@HHQuraishi
I'd like to discuss whether to create a separate class for orientation handling or include it directly where needed. Your insights on the approach would be appreciated. Factors include reusability, maintainability, code complexity, and project architecture.

Thank you for your guidance.

@moneytoo
Copy link
Owner

The videos play only in portrait mode. Even if the auto rotate is turned on the orientation does not change.

The videos play either in device orientation or in the best suited orientation for the current video. I can play landscape videos in landscape as well as portrait videos in landscape with device orientation and auto rotation turned on. If you still have issues, please post more detailed steps to reproduce such issue.

@HHQuraishi
Copy link
Author

@HHQuraishi I'd like to discuss whether to create a separate class for orientation handling or include it directly where needed. Your insights on the approach would be appreciated. Factors include reusability, maintainability, code complexity, and project architecture.

Thank you for your guidance.
I think you should make a separate class.
(PS: I am a student and still learning)

@HHQuraishi
Copy link
Author

I am a student and still learning

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

No branches or pull requests

3 participants