This is My code but when I start the mediaplayer it have only the sound come out and the surface have nothing shown . Why?
I have no idea on this. Do you have some code help me to learn with this.
    videoV = (SurfaceView) findViewById(R.id.SurfaceView1);
    sh = videoV.getHolder();
    File path = Environment.getExternalStorageDirectory();
    File file = new File(path, "sample2.mp4");
    sh.addCallback(this);     
    mp = new MediaPlayer();
    mp.setDataSource(file.getAbsolutePath());
    mp.setDisplay(sh);
    mp.prepare();
    mp.start();
Try to add after
sh.addCallback(this);
this
sh.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
In my case it was helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With