use*_*278 3 nsurl nsdictionary mpmovieplayercontroller ios
我有这个代码用于保存mp3文件
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [documentPath objectAtIndex:0];
NSString *fileName = [[NSString alloc] initWithFormat:@"%@%@.mp3", dateString ,timeString ];
NSURL* fileURL = [NSURL URLWithString:myString];
NSError* error = nil;
NSData* data = [NSData dataWithContentsOfURL:fileURL options:0 error:&error];
NSString *savePath = [docDirectory stringByAppendingPathComponent:fileName];
[data writeToFile:savePath atomically:YES];
Run Code Online (Sandbox Code Playgroud)
现在我想通过MPMoviePlayerController读取此文件
如何获取路径或nsurl文件
--- somthing代码一样
NSURL * urlv = [[NSURL alloc] initWithString:myString];
avPlayer = [[MPMoviePlayerController alloc] initWithContentURL:urlv];
[avPlayer prepareToPlay];
[avPlayer play];
Run Code Online (Sandbox Code Playgroud)
请帮助搜索mystrig或nsurl源代码
NSString *filename = @"whatever you've saved your filename as";
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *documentsDirectory = [pathArray objectAtIndex:0];
NSString *yourSoundPath = [documentsDirectory stringByAppendingPathComponent:filename];
if ([[NSFileManager defaultManager] fileExistsAtPath:soundPath])
{
NSURL *soundURL = [NSURL fileURLWithPath:soundPath isDirectory:NO];
}
//Then just init your player with the contents of that URL
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6493 次 |
| 最近记录: |