Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've a music player app and I wanna control system volume through a UISlider How can I do it? I've searched google and stack overflow but its showing something related to MPMusicPlayerController and MPVolumeView and that too not easy to understand. Is there any API for It. please do help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
220 views
Welcome To Ask or Share your Answers For Others

1 Answer

I love new learners... Simple answer for you...

First create a UIView in your StoryBoard, where you want to put a volume slider. Now create a IBOutlet for that view in your ViewController implementation.

for ex:

@property (nonatomic,strong) IBOutlet UIView* volumeView;

Now in the viewDidLoad method write the following code:

MPVolumeView *mpVolumeView = [[MPVolumeView alloc]initWithFrame:self.volumeView.bounds];
[self.volumeView addSubview:mpVolumeView];
[mpVolumeView sizeToFit];

Now you will have volume control in your app...

Note: this code will not work for a simulator.

cheers.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...