我的部分调整必须在收到特定消息时播放声音并显示 UIAlertView。然后当 UIAlertView 被取消时,声音停止。
目前, UIAlertView 出现了,但没有播放声音。这是我的代码
#define url(x) [NSURL URLWithString:x]
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
AVAudioPlayer *mySound;
mySound = [[AVAudioPlayer alloc] initWithContentsOfURL:url(@"/Library/Ringtones/Bell Tower.m4r") error:nil];
[mySound setNumberOfLoops:-1];
[mySound play];
[alert show];
[alert release];
[mySound stop];
[mySound release];