title: Capturing JavaScript Events in C# from YouTube API Using Awesomium
body: <p>Am I able to capture a JavaScript event, in C#, when generated as a result of the YouTube API while running in Awesomium?</p>
  
  <p>I have the following HTML which I load into my Awesomium browser:</p>
  
  <pre><code>&lt;body&gt;
      &lt;div id="player"&gt;&lt;/div&gt;
  
      &lt;script src="http://www.youtube.com/player_api"&gt;&lt;/script&gt;
      &lt;script&gt;
          var player;
  
          function onYouTubePlayerAPIReady() {
              player = new YT.Player('player', {
                  height: '390',
                  width: '640',
                  videoId: '0Bmhjf0rKe8',
                  events: {
                      'onReady': onPlayerReady,
                      'onStateChange': onPlayerStateChange
                  }
              });
          }
  
          function onPlayerReady(event) {
              event.target.playVideo();
          }
  
          function onPlayerStateChange(event) {
              if (event.data == 0) {
                  alert('done');
              }
          }
      &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>How can I capture the <code>onPlayerStateChange</code> (or another event generated by it) back in the C#, so that my application can react when the video ends?</p>