title: How to detect YTPlayerState.Ended using Swift?
body: <p>I'm playing You Tube videos in my app and trying to detect when a video is paused or ended? I've found the <code>kYTPlayerState</code> function in the .m file, but having trouble converting it's use to Swift. Here is what I have....</p>
  
  <pre><code>func playerView(playerView: YTPlayerView!, didChangeToState state: YTPlayerState)
  {
      switch (state) {
      case YTPlayerState.Playing:
          print("Started playback");
          break;
      case YTPlayerState.Paused:
          print("Paused playback");
          break;
      case YTPlayerState.Ended:
          print("Ended playback");
          break;
      default:
          break;
      }
  }
  </code></pre>
  
  <p>and .....</p>
  
  <pre><code>   if playerView(player , didChangeToState: YTPlayerState.Ended)
      {
          /// Do Something....
      }
  </code></pre>
  
  <p>....which I place in ViewDidLoad().   I'm also getting back the error on my if statement that says <code>Type "()" does not conform to protocol "Boolean Type"</code> .  If you know how to fix this, or if I'm leaving something out please help. </p>
  
  <p>I'm initializing the player in this view with <code>@IBOutlet var player: YTPlayerView!</code></p>