moneytoo / Player

▶ Simple and lightweight, yet polished and powerful Android video player based on ExoPlayer
https://play.google.com/store/apps/details?id=com.brouken.player
The Unlicense
1.44k stars 171 forks source link

Orientation #510

Closed HHQuraishi closed 9 months ago

HHQuraishi commented 10 months ago

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

Gauravkumar1502 commented 9 months ago

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 commented 9 months ago

Yes we can try

Gauravkumar1502 commented 9 months ago

@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 commented 9 months ago

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 commented 8 months ago

@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 commented 8 months ago

I am a student and still learning