错误“!dat”尝试设置(空)音频设备采样率
我正在尝试播放音频剪辑(使用 AVAudioPlayer)和视频剪辑(使用 MPMoviePlayerController),两者都正常工作。
然后我将这些文件签入 SVN 并在另一台 Mac 上将它们拉下来。 现在,当我运行该应用程序(iPad 应用程序)时,当它尝试播放音频或视频时,都会出现错误:
错误“!dat”试图设置(空)音频设备的采样率
计算出 SVN 损坏了文件, (尽管 Mac 的 QuickLook 可以很好地播放它们),我用它们在 Mac 上仍然可以使用的版本替换了它们。 但是我仍然收到错误。
所有代码在两台机器上都完全相同,但使用的原始 Mac (MacBook Pro) 会在模拟器中播放它们,但在第二台 Mac (Mac Pro) 上它们不会播放并给出此错误。
有谁知道这个错误意味着什么,或者我如何修复它(因为覆盖媒体文件不起作用)
感谢
播放音频的代码:
NSError *error;
[[AVAudioSession sharedInstance] setDelegate:self];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:&error];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Page_7.m4a", [[NSBundle mainBundle] resourcePath]]];
if (audioPlayer == nil)
{
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = 0;
}
if (audioPlayer == nil)
NSLog(@"%@", [error description]);
else
[audioPlayer play];
更新:如果我在我的iPad(从我的Mac Pro)上运行它,视频可以正常播放。它只是无法在我的 Mac Pro 模拟器上运行
I am trying to play an audio clip (using AVAudioPlayer) and a video clip (using MPMoviePlayerController), both of which were working.
I then checked the files into SVN and pulled them down on another Mac.
Now when I run the app (iPad app) when it tries to play either the audio or video, both give the error:
Error '!dat' trying to set the (null) audio devices' sample rate
Figuring that SVN corrupted the files, (even though the Mac's QuickLook will play them fine), I replaced them with the versions on the Mac where they still work.
However I am still getting the error.
All code is exactly the same on both machines, but the original Mac used (MacBook Pro) will play them both in the simulator, but on the second Mac (Mac Pro) they will not play and give this error.
Does anyone know what this error means, or how I can fix it (since overwritting the media files didnt work)
Thanks
Code for playing the audio:
NSError *error;
[[AVAudioSession sharedInstance] setDelegate:self];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:&error];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Page_7.m4a", [[NSBundle mainBundle] resourcePath]]];
if (audioPlayer == nil)
{
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = 0;
}
if (audioPlayer == nil)
NSLog(@"%@", [error description]);
else
[audioPlayer play];
Update: If I run it on my iPad (from my Mac Pro) the video plays fine. It just won't play on my Mac Pro's Simulator
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
几天来都有同样的问题(非常烦人)。我设法通过更改系统首选项下的音频输入设置来修复它。
系统偏好设置->声音->输入
had the same problem for several days (extremely annoying). I managed to fix it by changing the input settings for audio under system preferences.
System Preferences -> Sound -> Input
我也有同样的问题。这就是我所做的:
I had the same problem. Here is what I did:
再次重新安装,终于成功了。仍然不知道问题是什么
Did another reinstall and it finally worked. Still no idea what the problem was