2014-09-23 3 views
0

소리가 시작되면 멈추지 않습니다, 어떻게 멈추게합니까?iOS Swift; AVFoundation 반복 중지

import AVFoundation 

var audioPlayer2 = AVAudioPlayer() 
var Sound2 = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("filename", ofType: "aiff")!) 


override func viewDidLoad() { 
    super.viewDidLoad() 
    audioPlayer2 = AVAudioPlayer(contentsOfURL: Sound2, error: nil) 
    audioPlayer2.prepareToPlay() } 

fund update() { ~ ~ ~ ~ 

audioPlayer2.play() 

} 

나는

audioPlayer2.stop() 

을 시도하지만

답변

0

사용 AVPlayer를 작동하지 않습니다 :

var player:AVPlayer! 
var steamingURL:NSURL = NSURL(string:playerURL) 
player = AVPlayer(URL: steamingURL) 
player.play() 
관련 문제