title: Record video and while play display date and time of recording in video view surface: android
body: <p>i am able to record and save video in sdcard and able to play video from video view , but now i want to show recording date and time in side video view on top/Bottom of video view , so i am now stuck  here , what should i do now ..please any one done with this help , effort would be greatly appreciate here..</p>
  
  <p>FOr recording i used below code..:</p>
  
  <pre><code>   public class VideoRecorder extends Activity{
  
  //Create objects of MediaRecorder and Preview class  
       private MediaRecorder recorder;
  private Preview mPreview;
  
  boolean flag=false; 
  boolean startedRecording=false;
  boolean stoppedRecording=false;
  
  // In this method, create an object of MediaRecorder class. Create an object of 
  // RecorderPreview class(Customized View). Add RecorderPreview class object
  // as content of UI.     
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      recorder = new MediaRecorder();
      recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
      recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
      mPreview = new Preview(VideoRecorder.this,recorder);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
      setContentView(mPreview);
  
      }
  
  
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) 
  {
      super.onPrepareOptionsMenu(menu);
      menu.clear(); 
      menu.add(0, 0, 0, "Start Recording"); 
      menu.add(1, 1, 0, "Stop Recording");
  
      menu.setGroupVisible(0, false);
      menu.setGroupVisible(1, false);
  
      if(startedRecording==false)
          menu.setGroupVisible(0, true);
      else if(startedRecording==true&amp;&amp;stoppedRecording==false)
          menu.setGroupVisible(1, true);
  
      return true;
  }
  
  
   /*!
      &lt;p&gt;
      This method receives control when Item in menu option is selected. It contains implementations
      to be performed on selection of menu item. 
      &lt;/p&gt;*/
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) 
  {
      switch (item.getItemId()) 
      {
      case 0:
          //start the recorder
              recorder.start();
              startedRecording=true;
  
          break;
  
      case 1: 
          //stop the recorder
          recorder.stop();
          recorder.release();
          recorder = null;
          stoppedRecording=true;
          break;
  
  
      default:
          break;
      }
      return super.onOptionsItemSelected(item);
  }
  
  class Preview extends SurfaceView implements SurfaceHolder.Callback
  {
      //Create objects for MediaRecorder and SurfaceHolder.
      SurfaceHolder mHolder;
      MediaRecorder tempRecorder;
  
  
      public Preview(Context context,MediaRecorder recorder) {
          super(context);
          tempRecorder=recorder;
          mHolder=getHolder();
          mHolder.addCallback(this);
          mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
          // TODO Auto-generated constructor stub
      }
  
      public Surface getSurface()
      {
          return mHolder.getSurface();
      }
  
      // Implement the methods of SurfaceHolder.Callback interface
  
      // SurfaceCreated : This method gets called when surface is created.
      // In this, initialize all parameters of MediaRecorder object.
      //The output file will be stored in SD Card.
  
      public void surfaceCreated(SurfaceHolder holder){
          tempRecorder.setOutputFile("/sdcard/recordvideooutput.3gpp");
          tempRecorder.setPreviewDisplay(mHolder.getSurface());
          try{
              tempRecorder.prepare();
          } catch (Exception e) {
              String message = e.getMessage();
              tempRecorder.release();
              tempRecorder = null;
          }
      }
  
      public void surfaceDestroyed(SurfaceHolder holder) 
      {
          if(tempRecorder!=null)
          {
              tempRecorder.release();
              tempRecorder = null;
          }
      }
  
      public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) 
      {
  
      }
  </code></pre>