I developed an app for kids and it includes some practice tests so when the answer is correct I wrote code to display alert "correct"
. I want code for when displaying the alert "correct"
. It should also come along with voice.
Asked
Active
Viewed 39 times
-6

Alex Shesterov
- 26,085
- 12
- 82
- 103
-
3what is the platform your coding for? – Ahmad Kayyali Sep 17 '13 at 06:55
-
1Welcome to SO community, please read this,http://stackoverflow.com/questions/how-to-ask it will help you to improve your chance of getting the correct answer – Ahmad Kayyali Sep 17 '13 at 06:58
-
1in what kind is this related to performance? – LostAvatar Sep 17 '13 at 07:03
-
@AhmadKayyali, see Magic Links: http://meta.stackexchange.com/q/92060/185667 – brasofilo Sep 17 '13 at 07:04
-
@brasofilo: I know Magic Links, it's just I am Lazy : ) – Ahmad Kayyali Sep 17 '13 at 07:07
-
@AhmadKayyali - So, gimme the link to Lazy Links :P – brasofilo Sep 17 '13 at 07:09
-
@brasofilo: here you go [Lazy Links](http://www.lazylinks.co.uk/) – Ahmad Kayyali Sep 17 '13 at 07:10
1 Answers
2
Get the path of the audio and then start the audio with the alertview and then you can stop it when the button is pressed.Something like this..
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/yourAudio.mp3", [[NSBundle mainBundle] resourcePath]]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = 1;
[audioPlayer play];
[alert show];
Stop the audio here.
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex==0) {
[audioPlayer stop];
}
Note : Add AVAudio framework and if youdon't want to play the audio untill the button of UIAlertView is clicked then set audioPlayer.numberOfLoops = -1;

mrunmaya
- 41
- 6
-
how did you know it's not Android? is it **app for kids** that inspired you? – Ahmad Kayyali Sep 17 '13 at 07:13
-
1