title: Overriding YouTube's resume playback function?
body: <p>Does anyone know how to override YouTube's "resume playback" function? I need the embedded YouTube videos on my site to start from the beginning each time, rather than where the user last left off.</p>
  
  <p>In the past, the resume playback function on YouTube only worked on videos 20 minutes or longer, but in recent weeks YouTube seem to have rolled the function out to all videos.</p>
  
  <p>I assumed I could just set the start time to 0 seconds, or seek to 0 seconds after the player is initialised. But this doesn't work. Setting the start time to 0 via any method will cause the video to resume from where the user last left off (if the user is logged into YouTube).</p>
  
  <p>Here's my default YouTube iframe API code:</p>
  
  <pre><code>&lt;div id="yt-player"&gt;&lt;/div&gt;
  &lt;script&gt;
  
  var player;
  var tag = document.createElement('script');
  
  tag.src = "https://www.youtube.com/iframe_api";
  
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
  function onYouTubePlayerAPIReady() {
      player = new YT.Player("yt-player", {
          height: "433",
          width: "770",
          videoId: "[YOUTUBE_VIDEO_ID]",
          playerVars: {
              autoplay: 1,
              html5: 1,
              rel: 0
          },
          events: {
              onReady: onPlayerReady,
              onStateChange: onPlayerStateChange
          }
      })
  }
  
  function onPlayerReady(e) {
      //...
  }
  
  function onPlayerStateChange(e) {
      //...
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>So far I have tried:</p>
  
  <p><strong>Setting the start time to 0 seconds</strong></p>
  
  <pre><code>...
  
          playerVars: {
              autoplay: 1,
              html5: 1,
              rel: 0,
              start: 0
          },
  
  ...
  </code></pre>
  
  <p><strong>Seeking to 0 seconds on player ready</strong></p>
  
  <pre><code>function onPlayerReady(e) {
      player.seekTo(0);
  }
  </code></pre>
  
  <p><strong>Seeking to 0 seconds after player state = playing</strong></p>
  
  <pre><code>function onPlayerStateChange(e) {
      if(e.data==1)player.seekTo(0);
  }
  </code></pre>
  
  <p><strong>Setting autoplay to false, then calling playVideo() on player ready</strong></p>
  
  <pre><code>...
  
          playerVars: {
              autoplay: 0,
              html5: 1,
              rel: 0
          },
  
  ...
  
  function onPlayerReady(e) {
      player.playVideo();
  }
  </code></pre>
  
  <p>None of the above work (the seekTo on player ready did sometimes work, but more often not. The player would load at the users last position, seek to 0 as instructed, but then jump back to the users last position just before playback. I also tried seeking to -1 but with no luck)</p>
  
  <p>The only workaround I could find was to set the start to 1 second (or seek to 1 second on player ready). But this obviously is not an ideal solution.</p>
  
  <p>Does anyone have any suggestions or know a workaround? Thank you.</p>