Mute Unmute Device Volume in Objective C

MPMusicPlayerController *musicPlayer=[[MPMusicPlayerController alloc] init];

if(musicPlayer.volume>0)
{
musicPlayer.volume = 0.0;
}
else
{
musicPlayer.volume = 1.0;
}
//(Works only in device not in simulator)