title: Handle control buttons of UIwebview youtube video player
body: <p>I'm creating a youtube videos player which can play a list of youtube video ( given a list of video id). I embedded youtube video into a UIWebview as following:</p>
  
  <pre><code>NSString *htmlFormat = @"&lt;html&gt;&lt;head&gt;&lt;body style=\"margin:0\"&gt;&lt;embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" width=\"40\" height=\"30\"&gt;&lt;/embed&gt;&lt;/body&gt;&lt;/html&gt;";
  NSString *url = [NSString stringWithFormat:@"http://www.youtube.com/watch?v=%@", videoId];
  NSString *html = [NSString stringWithFormat:htmlFormat, url];
  [webView loadHTMLString:html baseURL:nil];
  </code></pre>
  
  <p>What i need are:</p>
  
  <ul>
  <li>Next video is played automatically when player finishes playing current one.</li>
  <li>Next video is played when user tap next button in players' control panel</li>
  <li>Stop playing list if user tap 'Done' button.</li>
  </ul>
  
  <p>My approach is handling events that may be sent out when player finish playing, users tap control buttons, so i can modify html content to load other videos. </p>
  
  <p>My question are:</p>
  
  <ol>
  <li><p><strong>Is there better way to play a list of youtube video given a list of video ids?</strong></p></li>
  <li><p><strong>How to handle such those events?</strong> </p></li>
  </ol>
  
  <p>I found <a href="https://stackoverflow.com/questions/8518719/how-to-receive-nsnotifications-from-uiwebview-embedded-youtube-video-playback/8554040#8554040">some solutions</a> that suggest handle notification <code>UIMoviePlayerControllerDidExitFullscreenNotification</code> and <code>UIMoviePlayerControllerDidEnterFullscreenNotification</code>, but I can not distinguish between control buttons' events and finish playing event (movie player controller exits fullscreen mode in all the cases). Some suggest using HTML <code>&lt;video&gt;</code> tag, but i dont think it possible.</p>