android - Screen rotation while playing video -


i playing video , has got fullscreen icon.on clicking on forcefully rotating device orientation landscape mode.but when rotate screen,the video locked landscape mode only.it not coming potrait mode.i want video rotation happen similar youtube/hotstar app,where change of rotation happens both on button click , device orientation change.kindly suggest way forward.

findviewbyid(r.id.landscape).setonclicklistener(new view.onclicklistener() {     @override     public void onclick(view view) {   setrequestedorientation(activityinfo.screen_orientation_sensor_landscape);     } } });  public void onconfigurationchanged(configuration newconfig) {     super.onconfigurationchanged(newconfig);     setautoorientationenabled(this,false); } 

question:
simple requirement after forcefully rotating activity using setrequestedorientation(activityinfo.screen_orientation_sens‌​or_landscape); how can again go potrait mode rotating device without calling setrequestedorientation(activityinfo.screen_orientation_sens‌​or_potrait);

for button can change using lines :

button buttonsetportrait = (button)findviewbyid(r.id.setportrait); button buttonsetlandscape = (button)findviewbyid(r.id.setlandscape);  buttonsetportrait.setonclicklistener(new button.onclicklistener(){     @override    public void onclick(view arg0) {         setrequestedorientation(activityinfo.screen_orientation_portrait);    }  });  buttonsetlandscape.setonclicklistener(new button.onclicklistener(){     @override    public void onclick(view arg0) {         setrequestedorientation(activityinfo.screen_orientation_landscape);    }  }); 

answer : https://stackoverflow.com/a/18268304
use following code set videos orientation when device orientation changes override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig);

    // checks orientation of screen     if (newconfig.orientation == configuration.orientation_landscape) {         toast.maketext(this, "landscape", toast.length_short).show();     } else if (newconfig.orientation == configuration.orientation_portrait){         toast.maketext(this, "portrait", toast.length_short).show();     } 

take @ answer : https://stackoverflow.com/a/5726776

for enable or disable auto rotate take @ answer: (https://stackoverflow.com/a/4909079/4585226)

import android.provider.settings; public static void setautoorientationenabled(context context, boolean enabled) {       settings.system.putint( context.getcontentresolver(), settings.system.accelerometer_rotation, enabled ? 1 : 0); } 

add permission androidmanifest.xml

<uses-permission android:name="android.permission.write_settings" /> 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -