Nan
Nan

Reputation: 524

Volume control of AVAudioPlayer instance

I am making a background audio for my current App. The audio is playing by initializing a AVAudioPlayer instance, like the following code:

var audioPlayer = AVAudioPlayer()

I have been reading the AVAudioPlayer's documents.

My question is : how to mute/unmute the audioPlayer and it is still playing in the background? Should I do it via volume control or any function that can swift on and off audio instantly? Thanks in advance.

Upvotes: 1

Views: 1515

Answers (1)

iwasrobbed
iwasrobbed

Reputation: 46703

The volume will be controllable by the person's volume buttons on the side of their device or you can set the volume via the volume property if you have a UI control visible for the person to mute it with.

https://developer.apple.com/documentation/avfoundation/avaudioplayer/1389330-volume

Upvotes: 2

Related Questions