I am trying to create a slider that controls volume of 4 audio files.
Here is my code for the audio:
var ButtonAudioURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("audio1", ofType: "mp3")!)
var firstplayer = AVAudioPlayer()
var ButtonAudioURL2 = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("audio2", ofType: "mp3")!)
var secondplayer = AVAudioPlayer()
var ButtonAudioURL3 = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("audio3", ofType: "mp3")!)
var thirdplayer = AVAudioPlayer()
var ButtonAudioURL4 = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("audio4", ofType: "mp3")!)
var forthplayer = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
firstplayer = AVAudioPlayer(contentsOfURL: ButtonAudioURL, error: nil)
secondplayer = AVAudioPlayer(contentsOfURL: ButtonAudioURL2, error: nil)
thirdplayer = AVAudioPlayer(contentsOfURL: ButtonAudioURL3, error: nil)
forthplayer = AVAudioPlayer(contentsOfURL: ButtonAudioURL4, error: nil)
I have the audio to play when each button is touched. But I just need to get a slider to control the volume of each audio file from each button.
How should i do this? I have looked at MPVolumeView class reference on developer.apple, but I am still confused and in the developer.apple reference for MPVolumeView, it talks about AirPlay, can I disable that?
I just need a slider to control the volume.