AVAusioSession pty error in simulator

I have a simple code to play sound through AVAudioPlayer

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                         pathForResource:@"beep"
                                         ofType:@"mp3"]];

self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
self.player.volume = 1;
[self.player prepareToPlay];

My exception checkpoint will stop at prepareToPlay, and the console log wrote:

ERROR: AVAudioSessionUtilities.h: 111: GetProperty: Error AudioSessionGetProperty ('prp?') With error: 'pty?

After double-clicking to go through this breakpoint, the application will not crash. This happened only in the simulator. Any suggestions?

+4
source share
2 answers

The following code might be helpful.

NSURL *url;
url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/beep.mp3", [[NSBundle mainBundle] resourcePath]]];
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
self.audioPlayer .delegate = self;
[self.audioPlayer  prepareToPlay];
[self.audioPlayer  play];
+1
source
0

Source: https://habr.com/ru/post/1569761/


All Articles