Error '!dat' trying to set the (null) audi

2019-02-17 08:00发布

问题:

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

回答1:

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



回答2:

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


回答3:

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