android - TextureView autorotate video stream on Nexus4 (but not on Galaxy S4) -


when playback video stream on textureview, saw different behaviors in galaxy s4 , nexus4.

the video source recorded android in portrait mode, video 90 degrees rotated. (android camera's default orientation landscape capture video in portrait, need rotate video 90 degrees clockwise) when playback first check orientation of video (by measuring width , height) , if width longer height, rotate textureview 90 degrees below code.

mediametadataretriever mediametadataretriever = new mediametadataretriever(); mediametadataretriever.setdatasource(url, new hashmap<string, string>()); string heightstring = mediametadataretriever.extractmetadata(mediametadataretriever.metadata_key_video_height); string widthstring = mediametadataretriever.extractmetadata(mediametadataretriever.metadata_key_video_width);  int videoheight = integer.parseint(heightstring); int videowidth = integer.parseint(widthstring);  framelayout.layoutparams l; displaymetrics metrics = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(metrics);  if(videowidth > videoheight){     log.d(tag, "need rotate 90");      l = new framelayout.layoutparams(metrics.heightpixels, metrics.widthpixels, gravity.center_horizontal | gravity.center_vertical);     textureview.setrotation(90);             }else{        l = new framelayout.layoutparams(metrics.widthpixels, metrics.heightpixels, gravity.center_horizontal | gravity.center_vertical); }         textureview.setlayoutparams(l); 

this works on galaxy s4 or xepria z, doesn't work on nexus4 or galaxy s2. seems in nexus4, textureview autorotates video 90 degrees, therefore below code, video in end rotated 180 degrees.

right have no way manage behavior difference among devices. have same experience , know how solve it, appreciate help.


Comments

Popular posts from this blog

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -