title: AVPlayer -- Observing rate to toggle play/pause buttons
body: <p>I'm using AVPlayer and I'm simply trying to toggle my play/pause button correctly. I can't just toggle based on user action because I'm starting/stopping the player automatically at times.</p>
  
  <p>So I'm observing the <code>rate</code> key of the AVPlayer, and when a notification is sent, I check the <code>rate</code>. </p>
  
  <ul>
  <li>If 0, then I show the "play" button. (Player is paused)</li>
  <li>If 1, then I show the "pause" button. (Player is playing)</li>
  </ul>
  
  <hr>
  
  <p>This works perfectly except for one situation. When the app goes to background and then becomes active again, the rate first goes to "1" and then to "0". So the button goes from "pause" to "play".</p>
  
  <p>However, the video keeps playing, but I never get another <code>rate</code> notification of "1".</p>
  
  <p>I even added this to code block that observes <code>rate</code>:</p>
  
  <pre><code>[self performSelector:@selector(logRate) withObject:nil afterDelay:3.0];
  </code></pre>
  
  <p>I'm just checking the rate again 3 seconds after the last "0" rate change was observed. The video is still playing but the rate is still "0".</p>
  
  <hr>
  
  <p>Does anyone know either:
  1. Why this would happen?
  2. Is there a better way to observe if an AVPlayer is playing or paused besides <code>rate</code>?</p>