Audio in Xcode7 abspielen
Ich versuche nur, Audio abzuspielen, wenn ich auf eine Schaltfläche tippe. Bei dieser Codezeile wird jedoch eine Fehlermeldung angezeigt.
ButtonAudioPlayer = AVAudioPlayer(contentsOfURL: ButtonAudioURL, error: nil)
Das ist mein ganzer Code:
import UIKit
import AVFoundation
class ViewController: UIViewController {
var ButtonAudioURL = NSURL(fileURLWithPath:NSBundle.mainBundle().pathForResource("Audio File 1", ofType: "mp3")!)
var ButtonAudioPlayer = AVAudioPlayer()
override func ,viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
ButtonAudioPlayer = AVAudioPlayer(contentsOfURL: ButtonAudioURL, error: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func playAudio1(sender: UIButton) {
}
}
Der Fehler ist
Incorrect argument label in call (habe 'contentsOfURL: error:', erwartet 'contentsOfURL: fileTypeHint:').
Wenn ich error in fileTypeHint ändere, funktioniert es immer noch nicht.