Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 播放前先挂接音频播放器_Ios_Avfoundation_Avaudioplayer - Fatal编程技术网

Ios 播放前先挂接音频播放器

Ios 播放前先挂接音频播放器,ios,avfoundation,avaudioplayer,Ios,Avfoundation,Avaudioplayer,我有一个带MP3文件的AVAudioPlayer。但在玩之前,你会听到一个信号。 这是我的代码: NSString *geluid = [NSString stringWithFormat:@"RG_%@", nummer]; NSString *path = [[NSBundle mainBundle] pathForResource:geluid ofType:@"mp3"]; AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] i

我有一个带MP3文件的AVAudioPlayer。但在玩之前,你会听到一个信号。 这是我的代码:

NSString *geluid = [NSString stringWithFormat:@"RG_%@", nummer];

    NSString *path = [[NSBundle mainBundle] pathForResource:geluid ofType:@"mp3"];
    AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];

    theAudio.delegate=self;
    [theAudio prepareToPlay];
    [theAudio play];

    NSURL *url = [NSURL fileURLWithPath:path];
    avplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
    [avplayer prepareToPlay];
    [avplayer play];
例如:你听到的是“到此为止”,而不是“到此为止”。
请帮我修复它。

这段代码是否同时运行两个AVAudioPlayer实例? 为什么你同时使用avplayer和音频? 从现在看来,你应该摆脱其中一个