我有一個帶有animateWithDuration和setAnimationRepeatCount()
動畫的脈衝矩形。animateWithDuration播放聲音不重複
我試圖在動畫塊中添加聲音效果的女巫是同步「點擊」。但音效只播放一次。我無法在任何地方找到任何提示。
UIView.animateWithDuration(0.5,
delay: 0,
options: UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.Repeat,
animations: {
UIView.setAnimationRepeatCount(4)
self.audioPlayer.play()
self.img_MotronomLight.alpha = 0.1
}, completion: nil)
聲音效果應播放四次,但不播放。
音頻執行:
//global:
var metronomClickSample = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("metronomeClick", ofType: "mp3")!)
var audioPlayer = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
audioPlayer = AVAudioPlayer(contentsOfURL: metronomClickSample, error: nil)
audioPlayer.prepareToPlay()
....
}
@IBAction func act_toggleStartTapped(sender: AnyObject) {
....
UIView.animateWithDuration(....
animations: {
UIView.setAnimationRepeatCount(4)
self.audioPlayer.play()
self.img_MotronomLight.alpha = 0.1
}, completion: nil)
}
動畫重複嗎? – ricky3350
聲音是否播放?音頻片段有多長? – dudeman
動畫重複。聲音只播放一次。音頻剪輯只是一個短的點擊:長度0.36秒,格式MP3 –