【发布时间】:2013-04-17 08:37:07
【问题描述】:
我正在录制视频并将其保存到文档文件夹,我想稍后使用视频路径再次播放,但它没有播放我正在使用以下代码获取文档文件夹中文件的路径,然后播放它
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setDateFormat:@"dd-MM-yyyy||HH:mm:SS"];
NSDate *now = [[[NSDate alloc] init] autorelease];
NSDate* theDate = [dateFormat stringFromDate:now];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"Default Album"];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil];
NSString *videopath= [[[NSString alloc] initWithString:[NSString stringWithFormat:@"%@/%@.mov",documentsDirectory,theDate]] autorelease];
NSLog(@"Vide Path %@",videopath);
NSString *path = [[NSBundle mainBundle] pathForResource:videopath ofType:@"mov" inDirectory:nil];
NSURL *movieURL = [NSURL fileURLWithPath:path];
player= [[ MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self presentMoviePlayerViewControllerAnimated:player];
你能帮帮我吗,谢谢。
【问题讨论】:
-
从您的代码中您没有保存您的视频。
-
@Vedchi 我正在从 ipad 录制视频,然后我按下使用按钮而不是保存
-
@Vedchi 你能帮我解决这个问题吗
-
然后使用您在文档目录中保存视频的路径,而不是上面构建的路径。使用 NSDateFormatter 和 NSDate,您正在创建一个实际上不存在于文档目录中的新路径。
标签: iphone ipad video mpmovieplayercontroller document