Hi I am developing android application in which I have one simple activity which contains button to start new activity. new activity contain surface view to show video. I know that prepare media player work on main thread that's why I use prepareAsync. SO my problem is like this. I click on activity stat button which start new activity and start loading video. If I click back before video start i.e. media player start() it come back to previous activity. But UI of that activity is not active for some time. That mean I am not able to click on start button for some time. After some time it become active again. Is there any one facing same problem. My code looks like :
@Override
public void surfaceCreated(SurfaceHolder arg0) {
// TODO Auto-generated method stub
Log.i("FFFFFFFFFFFFFFFFFFF ", "FFFFFFFFFFFFFFFFFFF ");
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDisplay(surfaceHolder);
try {
mediaPlayer.setDataSource(getApplicationContext(), targetUri);
mediaPlayer.prepareAsync();
//mediaPlayer.prepare();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mediaPlayer.start();
}
});
}
How to avoid this situation. Am I doing some thing wrong. Need help. Thank you.