tags:

views:

28

answers:

0

I have wrote video player code in android.But one problem that i am facing is When i debug my code video is playing properly but when i run this, video is not appeared only sound can be listen.

Any help would be appreciated.

This is main method of my video player.

private void playVideo(String url) 
 {
  try 
  {
   media.setEnabled(false);
   if (player==null) 
   {
    player=new MediaPlayer();
    player.setScreenOnWhilePlaying(true);
    //player.reset();
   }
   else 
   {
    player.stop();
    player.reset();
   }
   player.setOnErrorListener(this);
   player.setDataSource(url);
   player.setDisplay(holder);
   player.setAudioStreamType(AudioManager.STREAM_MUSIC);
   player.setOnPreparedListener(this);
   player.prepareAsync();
   player.setOnBufferingUpdateListener(this);
   player.setOnCompletionListener(this);
  }
  catch(IllegalStateException ex)
  {   
   try
   {
    player.reset();
    player.setOnErrorListener(this);
    player.setDataSource(url);
    player.setDisplay(holder);
    player.setAudioStreamType(AudioManager.STREAM_MUSIC);
    player.setOnPreparedListener(this);
    player.prepareAsync();
    player.setOnBufferingUpdateListener(this);
    player.setOnCompletionListener(this);
   }
   catch(Exception ex1)
   {
    ex1.printStackTrace();
   }
  }
  catch (Throwable t) 
  {
   Log.e(TAG, "Exception in media prep", t);
   goBlooey(t);
  }
 }