Hi i'm new in ios and i want to make an app that play radio, so the app working fine, but when i tried to include the volume to the app, it's cruch and gives me this error :
[AVPlayer setVolume:]: unrecognized selector sent to instance 0x9d4f500
2013-05-16 09:34:47.785 RadioFM[22061:12503] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AVPlayer setVolume:]: unrecognized selector sent to instance 0x9d4f500'
and here is my source code that i'm using :
in PlayerViewController.h:
@interface PlayerViewController : UIViewController
{ AVAudioPlayer *radioPlayer; IBOutlet UISlider *Volume; }
- (IBAction)Volume:(id)sender;
@property (nonatomic,retain) AVAudioPlayer *radioPlayer;
and in PlayerViewController.m:
@synthesize radioPlayer;
- (void)viewDidLoad
{
NSString *RadStream=<@Radio stream>;
NSURL *url=[NSURL URLWithString:RadStream];
NSError *error;
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
self.radioPlayer = [AVPlayer playerWithPlayerItem:playerItem];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self.radioPlayer play];
[super viewDidLoad];
}
and i have a slider view and on the action of this slider i have :
- (IBAction)Volume:(id)sender {
if (self.radioPlayer != nil)
{
self.radioPlayer.volume = Volume.value;
}
}
so please can any one help me on this ? Thank you advance.