我刚写了这段代码。按一个按钮听到声音。我导入了AudioToolBox。我打开并使用我的应用程序的前10次工作正常,但现在由于某种原因,听起来我的音频非常安静,即使我的手机上的音量一直很高,AVFoundation产生的音频听起来很好
任何人都知道如何做到这一点?
import AVFoundation
import AudioToolBox
@IBAction func buttonOne(sender: UIButton) {
var soundID: SystemSoundID = 0
let soundURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), "C-note", "mp3", nil)
AudioServicesCreateSystemSoundID(soundURL, &soundID)
AudioServicesPlaySystemSound(soundID)
let wSize : CGFloat = 20
let hSize : CGFloat = 35
let yPosition : CGFloat = 40
let dot = UIImageView()
dot.image = UIImage(named: "drop")
dot.frame = CGRect(x: 33, y: yPosition, width: wSize, height: hSize)
self.view.addSubview(dot)
let duration = 0.7
let delay = 0.0
let options = UIViewAnimationOptions.CurveEaseIn
UIView.animateWithDuration(duration, delay: delay, options: options, animations: {
dot.frame = CGRect(x: 33, y: 360, width: wSize, height: hSize)
}, completion: { animationFinished in
dot.removeFromSuperview()
})
}