3

ビデオレコーダーに残り時間を表示したい。現在、録画時間を表示しています。どうやって?

私のコードは次のとおりです。

UIImagePickerController*  Videopicker1 = [[UIImagePickerController alloc] init];
Videopicker1.delegate = self;
Videopicker1.sourceType = UIImagePickerControllerSourceTypeCamera;
Videopicker1.showsCameraControls = YES;
Videopicker1.videoQuality=UIImagePickerControllerQualityTypeLow;
Videopicker1.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; // kUTTypeMovie is actually an NSString.
Videopicker1.videoMaximumDuration = 30.0f; // limits video length to 30 seconds.
[self presentModalViewController:Videopicker1 animated:YES];

前もって感謝します。

4

2 に答える 2

3

VC.h ファイル

@interface VideoCaptureVC_iPhone : UIViewController
<UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
    UIImagePickerController *picker;
    NSTimer *videoTimer;

}

@property (nonatomic, retain) NSTimer *videoTimer;

vc.m ファイル

- (void)pickerCameraSnap:(id)sender{
    NSLog(@"start camera capture and timer");
    [picker startVideoCapture];
    self.videoTimer =  [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeValue) userInfo:nil repeats:YES];
}

必要に応じて計算を行い、テキスト @"TimeRemaining" を適切な場所に変更します。横向き表示用にテキストを回転させました。

-(void)changeValue{
    UILabel *textNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 100, 100)];
    textNameLabel.center = CGPointMake(30,285);
    textNameLabel.backgroundColor = [UIColor redColor];
    textNameLabel.text = @"TimeRemaining";
    textNameLabel.textColor = [UIColor whiteColor];
    CGAffineTransform transformRotate = CGAffineTransformMakeRotation((M_PI  / 2));
    textNameLabel.transform = transformRotate;

    UIView *myOverlay = [[UIView alloc] initWithFrame:self.view.bounds];
    UIImage *overlayImg = [UIImage imageNamed:@"CameraOverlay"];
    UIImageView *overlayBg;
    overlayBg = [[UIImageView alloc] initWithImage:overlayImg];
    [myOverlay addSubview:overlayBg];
    [myOverlay addSubview:textNameLabel];
    [picker setCameraOverlayView:myOverlay];
}

最後にタイマーを停止します

- (void)stopCamera:(id)sender{
    NSLog(@"stop camera");
    [self.videoTimer invalidate]; 

    [picker stopVideoCapture];
    [picker setCameraDevice:UIImagePickerControllerCameraDeviceRear];
}
于 2013-02-21T11:45:50.507 に答える
0

動画の最大時間を設定し、現在の長さを表示していると述べているため。

TimeRemaining = videoMaximumDuration - currentDuration; 
于 2013-01-03T11:26:17.777 に答える