Volume Control Using UIslider Iphone?

I am creating an application in which sound is played when a button is pressed and using UISlider, with which you can adjust the volume. Sometimes the sound volume is too high, and sometimes too low even after the iphone volume is increased to full. How can I keep the volume always high? any possible way to integrate system volume with slider volume? Using MPVolumview will cause my application to crash. The code that I use when I click the button is

NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
resourcePath = [resourcePath stringByAppendingString:@"/sound.mp3"];
NSLog(@"Path to play: %@", resourcePath);



player = [[AVAudioPlayer alloc] initWithContentsOfURL:
          [NSURL fileURLWithPath:resourcePath] error:&err];

    player.delegate = self;
    [player play];
    player.volume=.50;
    player.numberOfLoops=-10;

-(IBAction)slidervaluechanged 
{ player.volume=slider.value; }

}

+5
source share
1 answer

Hemant

, , player.volume, 1.0 ( ).

, , , 1.0

MPVolumeView ( , ), . player.volume 1.0 .

, MPVolumeView: http://developer.apple.com/iphone/library/documentation/MediaPlayer/Reference/MPVolumeView_Class/Reference/Reference.html MPVolumeView?

, , , Apple MPVolumeView, . , , ( , API). , , , , .

+3

All Articles