如何在 iOS 设备上播放 .mid 文件

发布于 2024-12-28 12:48:21 字数 595 浏览 2 评论 0原文

我尝试了 AVAudioPlayer 它不起作用。

 url= [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/test.mid", [[NSBundle mainBundle] resourcePath]]];

NSLog(@"URL Description is %@",[url description]);
NSError *error=nil;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if (error!=nil) {
    NSLog(@"Error is %@",[error localizedDescription]);
}
[audioPlayer play];

我收到此错误

Error is The operation couldn’t be completed. (OSStatus error 1954115647.)

我应该使用其他方法来执行此操作吗?有什么建议吗?

谢谢

I tried AVAudioPlayer it doesnt work.

 url= [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/test.mid", [[NSBundle mainBundle] resourcePath]]];

NSLog(@"URL Description is %@",[url description]);
NSError *error=nil;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if (error!=nil) {
    NSLog(@"Error is %@",[error localizedDescription]);
}
[audioPlayer play];

I get this error

Error is The operation couldn’t be completed. (OSStatus error 1954115647.)

Should I be using another method to do this? Any suggestions?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文