yusuf al qaradawi books in urdu and hindi
Category:1974 births
Category:Living people
Category:Saudi Arabian Muslims
Category:Saudi Arabian writers
Category:People from MedinaQ:
Displaying a sound in a Swift app
I'm trying to make an app that requires sound and I'm not familiar with Swift and I found this tutorial. However, I have been trying to get this working for over 4 hours and I'm not getting anywhere. The problem is this:
import UIKit
import AVFoundation
import Foundation
class ViewController: UIViewController, AVAudioPlayerDelegate {
var soundName:String = ""
var soundPlayer:AVAudioPlayer?
var soundFile:AVAudioPlayer?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let filepath:NSURL = NSBundle.mainBundle().URLForResource(soundName, withExtension: "mp3")!
var error:NSError?
soundFile = AVAudioPlayer.sharedInstance().initWithContentsOfURL(filepath, error: &error)
if soundFile!= nil {
if let error = error {
NSLog("%@", error)
}
soundPlayer = soundFile!
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func playSound(sender: AnyObject) {
if soundPlayer!= nil {
soundPlayer?.stop()
soundPlayer = nil
}
if soundFile!= nil {
soundFile!.play()
}
}
override func touchesBegan(touches: Set, withEvent event: UIEvent be359ba680
Related links:
留言