带范围滑块的IOS trim视频
我正在使用范围滑块来修剪跑步视频。但我无法在特定时间停止视频。以下是我正在使用的代码:带范围滑块的IOS trim视频,ios,video,slider,Ios,Video,Slider,我正在使用范围滑块来修剪跑步视频。但我无法在特定时间停止视频。以下是我正在使用的代码: - (void)videoRange:(SAVideoRangeSlider *)videoRange didChangeLeftPosition: (CGFloat)leftPosition rightPosition:(CGFloat)rightPosition { self.startTime = leftPosition; self.stopTime = rightPosition
- (void)videoRange:(SAVideoRangeSlider *)videoRange didChangeLeftPosition: (CGFloat)leftPosition rightPosition:(CGFloat)rightPosition
{
self.startTime = leftPosition;
self.stopTime = rightPosition;
[self.movieController stop];
MPMoviePlayerController *player = self.movieController;
[player stop];
[player setCurrentPlaybackTime:self.startTime];
[player setEndPlaybackTime:self.stopTime];
[player play];
}
setCurrentPlaybackTime正在工作,但“setEndPlaybackTime”不工作。
请帮助我推进我的项目工作。
谢谢
Rohan我记不起我在哪里买的测距滑块,但这一个可能更好 我有一个可以很容易地给你一系列的值。下面是一些代码。最小值表示第一个滑块值,最大值表示第二个滑块值 h m
我希望这有点帮助。你所需要做的就是把这些碎片拼在一起。您可以从这里获得SVProgress:我正在从事完全相同的项目。
AVAssetExportSession *exportSession;
float max;
float min;
- (void)trimVideo:(NSString *)outputURL assetObject:(AVAsset *)asset
{
@try
{
exportSession = [[AVAssetExportSession alloc]initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
exportSession.outputURL = [NSURL fileURLWithPath:outputURL];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTime start = CMTimeMakeWithSeconds(min, 1);
CMTime duration = CMTimeMakeWithSeconds((max - min), 1);
CMTimeRange range = CMTimeRangeMake(start, duration);
exportSession.timeRange = range;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[self checkExportSessionStatus:exportSession];
exportSession = nil;
}
@catch (NSException * e)
{
NSLog(@"Exception Name:%@ Reason:%@",[e name],[e reason]);
}
}
- (void)checkExportSessionStatus:(AVAssetExportSession *)exportSession
{
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
{
switch ([exportSession status])
{
case AVAssetExportSessionStatusCompleted:
{
[[[UIAlertView alloc] initWithTitle:@"Video Trimmed"
message:@"Your trimmed video has been sent to your finished videos."
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil] show];
// dismiss progress bar or i use the SVProgress framework [SVProgressHUD dismiss];
// you can save it here
break;
}
case AVAssetExportSessionStatusFailed:
{
NSLog(@"Error in exporting");
[[[UIAlertView alloc] initWithTitle:@"Export fail"
message:nil
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil] show];
}
break;
default:
{
break;
}
}
}];
}