mercredi 6 mai 2015

cannot change class variables while runtime swift

That's an what I want to do. I want to change a class variable while the project is running and use that in player.

let pa = PlayerAv()

class PlayerAv
{
    var audioLink = ""
    var player: AVPlayer
    init()
    {
        player = AVPlayer(URL: NSURL(string: self.audioLink))
    }
}

@IBAction func changeToSabiha() {
    pa.player.pause()
    PlayerAv().audioLink = "http://ift.tt/1cnbIQ0"
    println("\(pa.audioLink)")
    pa.player.play()
}

Aucun commentaire:

Enregistrer un commentaire