title: Reliable way to detect end of video in a playlist
body: <p>I need to reliably capture the end of a video in a playlist by means of <em>Selenium WebDriver</em>. The playlist works like this: ad -> short video -> ad -> another video -> ....
  I need to detect when the n-th video ends.</p>
  
  <p>Technically it can be any player: JW8, VideoJS or any other, so I would prefer a generic solution without the necessity to support each and every player out there and their API. Each video is served as HTML5 video. When the next short video is served, the <code>src</code> attribute of the <code>&lt;video&gt;</code> tag changes.</p>
  
  <p>So far I was doing like this:</p>
  
  <pre><code>    _helper.StartVideoPlayback(Constants.START_PLAYBACK_XPATH);
      WebElement player = _seleniumWebDriver.findElement(By.xpath(videoxPath));
      //wait for the video to play
      _webDriverWait.until(ExpectedConditions.stalenessOf(player));
  </code></pre>
  
  <p>Which worked like a charm in Chrome: when the the video ends, the corresponding <code>WebElement</code> became stale.</p>
  
  <p>However, Safari just keeps playing the playlist further.</p>
  
  <p>So my question is basically twofold:</p>
  
  <ol>
  <li>What's the most reliable way to detect the end of video?</li>
  <li>Why is Safari webdriver thinking the video, whose <code>src</code> changed, is the same element?</li>
  </ol>