Search code examples
iosswiftavplayer

AVPlayer ReadyToPlay enum is an unresolved identifier


Using the Apple docs on AVPlayer, the player status should player.status == ReadyToPlay enum when it's ready.

I'm finding that Xcode is returning it as an unresolved identifier - I've looked through the docs from Apple, as well as previous answers from here but nothing is working.

My imports are:

UIKit
AVFoundation
MediaPlayer

here's the code:

//observer for AVPlayer
override func observeValueForKeyPath(keyPath: String,
    ofObject object: AnyObject, change: [NSObject : AnyObject],
    context: UnsafeMutablePointer<Void>) {
        if keyPath == "status" {
            println("Change at keyPath = \(keyPath) for \(object): result \(change)")
            if player.status == ReadyToPlay { 
                //unresolved identifier    
            }
        }
}

Solution

  • Missed the . from the enum:

    if player.status == .ReadyToPlay { ... }