0

みんな助けて:) AVAudioPlayerでオーディオをアプリで動作させるために、私は絶対にすべてを試しました。何らかの理由で、iPhone シミュレーターで再生されません。コードは次のとおりです-

#import "ViewController.h"
#import "AVFoundation/AVFoundation.h"

@interface ViewController ()
{
    AVAudioPlayer *avPlayer;
}

@end

@implementation ViewController
@synthesize myProgressView;
@synthesize sliderVolumeOutlet;

- (void)viewDidLoad
{
    [super viewDidLoad];

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

    NSError *error;

    avPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
    [avPlayer setNumberOfLoops:1];

    [avPlayer setVolume:self.sliderVolumeOutlet.value];
    [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updateProgress) userInfo:nil repeats:YES];    
}

曲自体はプロジェクトファイルにありますが、何が間違っているのか本当にわかりません。

4

1 に答える 1