Juli IchSelber
Juli IchSelber

Reputation: 69

AVAudioPlayer no sound when device is muted

How is the easiest way to program the AVAudioPlayer in the way that it is not playing music, while the device is muted(the physical slider on the left hand side is switched towards back of the phone)? It should just play music, if the device is unmuted.

Upvotes: 0

Views: 480

Answers (1)

Purteeek
Purteeek

Reputation: 159

you can have a slider that controls the volume for your AVAudioplayer, and an outlet for the slider that gets the value of the slider. When the slider value is set to zero that means when the volume is zero just use "youplayername.pause()" to pause the audio and when the volume is not zero, you can have two cases i.e. the audio is playing or the audio is paused. so you can set a boolean for condition of audio playing and code it accordingly. Use nested if else to achieve this result. I hope this answer helps you.

Upvotes: 1

Related Questions