Problem with playing a sound when a button is clicked.

Posted by iSharreth on Stack Overflow See other posts from Stack Overflow or by iSharreth
Published on 2010-03-31T03:52:07Z Indexed on 2010/03/31 3:53 UTC
Read the original article Hit count: 406

in my code:

import "MyViewController.h"

import

  • (IBAction)playSound{ AVAudioPlayer *myExampleSound;

    NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"];

    myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL];

    myExampleSound.delegate = self;

    [myExampleSound play];

}

But it is showing a warning that Class MyViewController does not implement AVAudioplayerDelegate.

Anyone please help. I had included the AVFoundation.Framework.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk