错误“!dat”尝试设置(空)音频设备采样率

发布于 2024-11-25 09:00:34 字数 1143 浏览 2 评论 0原文

我正在尝试播放音频剪辑(使用 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 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏末的微笑 2024-12-02 09:00:34

几天来都有同样的问题(非常烦人)。我设法通过更改系统首选项下的音频输入设置来修复它。

系统偏好设置->声音->输入

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

洋洋洒洒 2024-12-02 09:00:34

我也有同样的问题。这就是我所做的:

  • 关闭 xcode 和 iOS 模拟器
  • 拔下耳机插孔和您可能拥有的任何 USB 耳机
  • 重新启动 xcode 并运行您的模拟(问题应该得到解决)
  • 重新插入您想要使用的任何音频设备

I had the same problem. Here is what I did:

  • Close xcode and the iOS simulator
  • Unplug the headphone jack and any usb headphones you might have
  • Restart xcode and run your simulation (problem should be solved)
  • Plug back in any audio devices you want to use
世界和平 2024-12-02 09:00:34

再次重新安装,终于成功了。仍然不知道问题是什么

Did another reinstall and it finally worked. Still no idea what the problem was

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文