android - why my video doesnot fit the size of the texture as i change the size of the texture -


iam trying animate video rendered using texture view, animation works fine , when scale texture different size media player not scale fit size of texture,the video playing full screen in background , can see part of video when scale texture
code works fine on android devices running android 4.0 not work on devices later versions of android . heres code animation kindly tell me problem ..

public class mainactivity extends activity implements textureview.surfacetexturelistener{ animationset animset; textureview mytexture; mediaplayer mmediaplayer; surface s; int height; static final string logfilename = "log"; int width; protected void oncreate(bundle savedinstancestate) {   super.oncreate(savedinstancestate);    mytexture = new textureview(this);   mytexture.setsurfacetexturelistener(this);   setcontentview(mytexture);        }     @override    public void onsurfacetextureavailable(surfacetexture arg0, int arg1,    int arg2) {      string mediastoragedir = environment.getexternalstoragepublicdirectory(             environment.directory_downloads).getabsolutepath(); s = new surface(arg0);     try {        mmediaplayer= new mediaplayer();        mmediaplayer.setsurface(s);        mmediaplayer.setdatasource(mediastoragedir+"/airindia.mp4");        mmediaplayer.setaudiostreamtype(audiomanager.stream_music);        mmediaplayer.prepareasync();        mmediaplayer.setlooping(true);        mmediaplayer.setonpreparedlistener(new onpreparedlistener() {             @override             public void onprepared(mediaplayer mp) {                  mmediaplayer.start();              }         });      // animate texture          animset =new  animationset(true);      animset.addanimation(scaling);      animset.addanimation(translate);      animset.setstartoffset(20000);    animation fulscaling = new scaleanimation(1.0f, 1.3333f, 1.0f, 1.3333f);      translateanimation fulltranslate = new translateanimation(         animation.relative_to_self, 0.0f,animation.relative_to_self, -0.3333f,        0, 0.0f, 0, 0.0f);           fulltranslate.setstartoffset(10000);          animset.setduration(1000);         animset.setfillafter(true);         animset.setfillenabled(true);         fulscaling.setstartoffset(10000);          animset.addanimation(fulscaling);     animset.addanimation(fulltranslate);        mytexture.setanimation(animset);        animset.setanimationlistener(new animationlistener() {            @override           public void onanimationend(animation arg0) {                mytexture.startanimation(animset);           }            @override           public void onanimationrepeat(animation arg0) {               // todo auto-generated method stub            }            @override           public void onanimationstart(animation arg0) {               // todo auto-generated method stub            }        });         } catch (illegalargumentexception e) {     showtoast(e.getmessage());     e.printstacktrace(); } catch (securityexception e) {     showtoast(e.getmessage());     e.printstacktrace(); } catch (illegalstateexception e) {     showtoast(e.getmessage());     e.printstacktrace(); } catch (ioexception e) {     showtoast(e.getmessage());     e.printstacktrace(); }  

}

if want scale textureview's contents, use settransform(). example, see adjustaspectratio() in grafika's playmovieactivity class, changes size of textureview contents match aspect ratio of video being played.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -