1

iOS13.1 AVAudioPlayer objective-c Error:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x48)

AVAudioPlayer+Extension.h file:

@interface AVAudioPlayer (Extension)

- (instancetype)initWithFilepath:(NSString*)filepath
                       delegate:(id<AVAudioPlayerDelegate>)delegate;

AVAudioPlayer+Extension.m file:

#import "AVAudioPlayer+Extension.h"

@implementation AVAudioPlayer (Extension)

@implementation AVAudioPlayer (Extension)

- (instancetype)initWithFilepath:(NSString*)filepath
                        delegate:(id<AVAudioPlayerDelegate>)delegate {

    NSError *error;
    NSURL *url = [NSURL fileURLWithPath:filepath];
    AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url
                                                                   error:&error];

    if (error != nil) {
        NSLog(@"AVAudioPlayer init failed %@", [error localizedDescription]);
        return nil;
    }


    player.currentTime = 0;
    player.delegate = delegate;

    return player;
}
Kevin
  • 16,549
  • 8
  • 60
  • 74
SUI HWANG
  • 11
  • 1

0 Answers0