java音频无法播放_无法播放文件中的音频文件?

当我尝试播放音频时,会出现此错误

2010-08-27 09:13:40.466 VoiceRecorder [1]原因失败:操作无法完成。 (OSStatus 错误-43.)

这是什么意思

我正在将文件存储在 Iphone Document 文件夹中,并在我的数据库中复制其名称

所以,当我从数据库中播放它时,它正确获取文件路径

和文件和数据库中的文件名完美地连接但无法播放

2010-08-30 12:22:00.592 VoiceRecorder [2] /Users/Username/Library/Application Support/iPhone Simulator/4.0.1/Applications/4BF0B5C7-59C9-462F-94EC- 662EBCE8505E/Documents/30Aug10_12_21_58.aif 2010-08-30 12:22:00.593 VoiceRecorder [3] 30Aug10-43.)21_58.aif 2010-08-30 12:22:00.618 VoiceRecorder [4]原因失败:操作无法完成。 (OSStatus 错误-43.)

急需回复

这是我的代码

-(IBAction)playevent{

VoiceRecorderAppDelegate *appDelegate=(VoiceRecorderAppDelegate*)[[UIApplication sharedApplication]delegate];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDir = [paths objectAtIndex:0];

NSString *fullpath = [documentsDir stringByAppendingPathComponent:appDelegate.filenamefrompath];

NSFileManager *fileManager = [NSFileManager defaultManager];

// Check if the database has already been created in the users filesystem

BOOL success = [fileManager fileExistsAtPath:fullpath];

// If the database already exists then return without doing anything

if(success) { NSLog(@"Yes exists"); }else{ NSLog(@"no"); }

//return [documentsDir stringByAppendingPathComponent:appDelegate.filenamefrompath];

NSError* err;

NSLog(@"%@",fullpath);

player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:fullpath] error:&err];

//NSString *filePath = [[NSBundle mainBundle] pathForResource:appDelegate.filenamefrompath ofType:@"aif"];

// NSURL * fileURL = [[7] initFileURLWithPath:filePath]; // player = [[8] initWithContentsOfURL:fileURL error:nil];

NSLog(@"%@",appDelegate.filenamefrompath);

player.delegate = self;

if( err ){

//bail!

NSLog(@"Failed with reason: %@", [err localizedDescription]);

}

[player play];

}

请检查我的代码是否有错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值