@IBAction
 public void toggleRecording() {
   if (!movieFileOutput.isRecording()) {
     recordButton.setImage(UIImage.create("player_stop"), UIControlState.Normal);
     startRecording();
   } else {
     recordButton.setImage(UIImage.create("player_record"), UIControlState.Normal);
     movieFileOutput.stopRecording();
     if (timer.isValid()) {
       timer.invalidate();
     }
   }
 }
  private void setupTimer() {
    timeMin = 0;
    timeSec = 0;

    final String timeNow = String.format("%02d:%02d", timeMin, timeSec);
    timeLabel.setText(timeNow);

    timer =
        NSTimer.createScheduled(
            1.0,
            new VoidBlock1<NSTimer>() {
              @Override
              public void invoke(NSTimer nsTimer) {
                timeSec++;
                if (timeSec == 60) {
                  timeSec = 0;
                  timeMin++;
                }
                final String timeNow = String.format("%02d:%02d", timeMin, timeSec);
                timeLabel.setText(timeNow);
              }
            },
            true);
    NSRunLoop.getCurrent().addTimer(NSRunLoopMode.Default, timer);
  }