I'm building video player with android media player object. i'm able to hear the audio but the video does not appear on surfaceView. here is my code
public class PlayerActivity extends Activity implements SurfaceHolder.Callback {
String path;
private MediaPlayer mp;
private SurfaceView mPreview;
private SurfaceHolder holder;
boolean pausing = false;
public static String filepath;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
getWindow().setFormat(PixelFormat.UNKNOWN);
mPreview = (SurfaceView)findViewById(R.id.surfaceView);
holder = mPreview.getHolder();
holder.setFixedSize(176, 144);
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mp = new MediaPlayer();
mp.setDisplay(holder);
try {
Intent intent = getIntent();
Uri fileuri = intent.getData();
filepath=fileuri.getPath();
} catch(Exception e) {}
try {
mp.setDataSource(filepath);
mp.prepare();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
mp.start();
}
}
target is android 2.3 and above. how to fix it please help me..