gpt4 book ai didi

iphone - 在iPhone SDK上播放mp3吗?

转载 作者:行者123 更新时间:2023-12-02 22:48:04 26 4
gpt4 key购买 nike

-(IBAction)musiconButtonClicked:(id)sender{
NSString *path = [[NSBundle mainBundle] pathForResource:@"NextRevIt" ofType:@"mp3"];
AVAudioPlayer* audioPlayer = [[AVAudioPlayer alloc ] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer play];
}


-(IBAction)musicoffButtonClicked:(id)sender{
[audioPlayer stop]; <----says this is undeclared?
}

我可以使音频正常播放,但是如何制作一个停止音频的按钮?

最佳答案

将其放在interface.h块中。

AVAudioPlayer* audioPlayer;

您将需要检查实例并释放它。

关于iphone - 在iPhone SDK上播放mp3吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2202607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com