Home AVAudioPlayer not playing sound from temp file path
Reply: 0

AVAudioPlayer not playing sound from temp file path

user1291 Published in May 28, 2018, 10:03 am

I have saved a recording to my Temp directory and can verify this using iExplorer

The file path structure is TempFolder/UserID/SoundName001.wav The bit I save to the database is UserID/SoundName001.wav

Here is the code I use to play the file

@property (nonatomic, strong) AVAudioPlayer *player;

-(void) playSound: (NSIndexPath*)recordingIndex {
    NSArray *recording = [recordingArray objectAtIndex:recordingIndex.item-1];
    NSString *filePath = [NSString stringWithFormat:@"%@%@",NSTemporaryDirectory(),[recording objectAtIndex:2]];
    NSURL *recorderURL = [[NSURL alloc] initFileURLWithPath: filePath];
    self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:recorderURL error:nil];
    [self.player prepareToPlay];
    [self.player setMeteringEnabled:YES];
    [self.player setDelegate:self];
    [self.player play];

I set a breakpoint and recorderURL returns the following file:///private/var/mobile/Containers/Data/Application/0883D0DC-B1FD-4D06-A7BB-EBD9EEF5D607/tmp/1/Dog001.wav

When I call this method, nothing happens, no crash, no sound... Am I missing something obvious here?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.370002 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO