title: HTML5 video player behavior on iPhone and iPod in Safari Web Apps
body: <p>On the iPhone and iPod, if a YouTube video is embedded in a web page, the user can touch the video and the video will start playing—the iOS media player slides in and the video plays full screen in landscape orientation. Once the video has finished playing, the iOS media player slides back out, revealing the web page where the video was embedded.  </p>
  
  <p>Using the HTML5 <code>&lt;video&gt;</code> tag, the user can touch the video and the video will "zoom" to full screen and start playing in whatever the current device orientation is. Once the video has finished playing, the user must tap once to bring up the player controls, and then tap "Done" in order to return to the web page.</p>
  
  <p>Unfortunately, uploading my videos to YouTube is not an option for this application, and I haven't found an HTML5 video player that returns to the website after the video is finished playing. I would prefer either that the video player exhibits the same behavior as the YouTube embedded videos, or that the video plays inline. Forcing inline video is possible in a customized <code>UIWebView</code>, but unfortunately that is not an option (as this is meant to be a web app, not a native app). Additionally, the <code>&lt;video&gt;</code> property <code>webkit-playsinline</code> does not work.</p>
  
  <p>Are there any HTML5 video players that can replicate the embedded YouTube video behavior? Am I missing any obvious Javascript workarounds? Is there a method to tell the window that the video is finished playing without user interaction?</p>
  
  <p>EDIT:</p>
  
  <p>Thanks to Jan, this problem is solved. Working code follows, along with a list of mistakes/notes.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;title&gt;scratchpad&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;video id="video"&gt;
      &lt;source src="movie.mp4" type="video/mp4" /&gt;
  &lt;/video&gt;
  &lt;script type="text/javascript"&gt;
  document.getElementById('video').addEventListener('ended',function(){document.getElementById('video').webkitExitFullScreen();},false);
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Mistakes I made:<br>
  1. Forgot to add an ID in the <code>&lt;video&gt;</code> tag.<br>
  2. Testing for <code>webkitSupportsFullscreen</code>—I couldn't ever get that property to test as "true." A comment in code in <a href="http://www.wowzamedia.com/forums/showthread.php?7602-Ipad-streaming" rel="nofollow noreferrer">this forum post</a> says,  </p>
  
  <pre><code>// note: .webkitSupportsFullscreen is false while the video is loading
  </code></pre>
  
  <p>but I was unable to create a condition in which it returned true.<br>
  3. Completely missed <a href="https://stackoverflow.com/questions/4497789/mobile-safari-video-question">this stackoverflow post</a>.</p>