相关疑难解决方法(0)

iPhone应用程序中不同声音之间的延迟

我正在尝试制作一个带有一些按钮的小型iPhone应用程序来播放WAV声音.我的按钮工作,但我有一个小延迟(~0.5秒).

这是我的.m文件:

#import "buttonSoundViewController.h"

@implementation buttonSoundViewController
//@synthesize player;

-(IBAction) playSoundA:(id)sender{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"a" ofType:@"wav"];
    AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
    theAudio.delegate = self;
    [theAudio play];
}

-(IBAction) playSoundB:(id)sender{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"b" ofType:@"wav"];
    AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
    theAudio.delegate = self;
    [theAudio play];
}

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
    [player release];
}

-(void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error {
}

-(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player {
}

-(void)audioPlayerEndInterruption:(AVAudioPlayer *)player {
}

- (void)didReceiveMemoryWarning {
    [super …
Run Code Online (Sandbox Code Playgroud)

iphone audio cocoa-touch latency objective-c

3
推荐指数
1
解决办法
2693
查看次数

标签 统计

audio ×1

cocoa-touch ×1

iphone ×1

latency ×1

objective-c ×1