gpt4 book ai didi

objective-c - xCode-如何在发生另一 Action 时停止该 Action

转载 作者:行者123 更新时间:2023-12-01 18:33:17 24 4
gpt4 key购买 nike

我有一个可以说语言的应用程序。但是,当按下单词B时,我想停止单词A。有没有办法做到这一点?这是我讲这些单词的代码:

-(IBAction)sayIt:(id)sender
{
//NSLog(@"%s", __FUNCTION__);
CFBundleRef mainBundle = CFBundleGetMainBundle();
FlashCardsAppDelegate *mainDelegate = (FlashCardsAppDelegate *)[[UIApplication sharedApplication] delegate];
CFURLRef soundFileURLRef;
soundFileURLRef= CFBundleCopyResourceURL (mainBundle, (CFStringRef)[mainDelegate soundFile], CFSTR("caf"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}

最佳答案

您可以将AVAudioPlayer用作类成员,
call player.stop和player.play以停止和启动音频。
如果您需要在停止播放器后更改声音,请使用InitWithData

关于objective-c - xCode-如何在发生另一 Action 时停止该 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5366761/

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