Volume control in iPhone OS from another view controller? -


If I'm playing a sound in a scene, does anyone know whether it is possible to control the volume from the other Is this what someone can explain this? I can not understand it, I have no code to show for the volume.

The sound is called from one view and the volume slider is on the other. I have coded both.

Code for sound

  # import` & lt; AVFoundation / AVAudioPlayer.h` & gt; #import "LeftViewController.h" @implementation LeftViewController - (IBAction) buttonrm: (id) This {[self dismissModalViewControllerAnimated: YES]; } - (IBAction playlame [[Audio play]; } - (IBAction) Poszel {[Audioso Paus]; } / * // Override the named initializer If you want to optimize the controller program that is not suitable for the visibility and make the DIDLoad. - (id) initWithNibName: (NSString *) nibNameOrNil Bundle: (NSBundle *) nibBundleOrNil {if (self = [super initWithNibName: nibNameOrNil Bundle: nibBundleOrNil]) {// custom initialization} return self; } * / // Apply the viewDidload to additional setup after loading the view, especially with a nibb. - (void) viewDidLoad {NSString * path = [[NSBundle mainBundle] pathForResource: @ "noisettes - Never Forget" ofType: @ "MP3"]; TheAudio = [[AviPlayer] alloc] initWithContentsOfURL: [NSU fileURLWithPath: Path] Error: NULL]; TheAudio.delegate = self; // [audio play]; [Super viewedload]; } // Override to allow orientations other than the default portrait orientation - (bool) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {// Return leaning back supported Yes (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } - (zero) did the Reciever Memory Warning {// See if there is no Supervisor then it releases [Super Dareceywamari Warning]; // Use any cached data, images, etc. which are not in use. } - (zero) viewDidUnload {// Release main view of any maintained subviews // eg. Self.myOutlet = Zero; } - (zero) Delok [[Super Delooc]]; } @end  

code for slider

  - (zero) viewDidoadload {[Super Viewedload]; CGRact sliders = CGRactam (46,124,190,0); UISLider * VolumeLL = [[UISLider Elock] InitWith Frame: SliderRect]; VolumeL.minimumValue = 0; VolumeL.maximumValue = 100; Volume L.continuous = Yes; UIImage * sliderctrl = [UIImage imageNamed: @ "volume_club"]]; // UIImage * stetchLeftTrack = [[UIImage imageNamed: @ "volumel12.png"] //stretchableImageWithLeftCapWidth:1.0 topCapHeight: 0.0]; [Volume settable image: sliderTretal Forestate: UIControlStateAnimal]; // [volume setmeattrack image: steve latef forkst: uissentolstadt normal]; [Volume edit: Target: Self-action: Control events for: @sillector: UI ControlAventWolves]; VolumeL.transform = Cig finan transformatorate (volume transform, 270.0 / 180 * mopi); [Self.view addSubview: VolumeL]; [Volume release]; }  

Use representative patterns

In the second scene controller For example, create a protocol called MyProtocol with one method:

  - (zero) doneUpdateVolume: (NSUInteger) quantity;  

Also create a representative example variable to capture a representative representative

  @property (nonatomic, assigned) id < MyProtocol & gt; Representative;  

And do not forget to implement it in the implementation.

When the volume price is updated, you send the value to the representative

  [self Delegate didUpdateVolume: newValue];  

is back to the first controller, adopt MyProtocol protocol didUpdateVolume implementation, and determine the value of your player.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -