title: How to play youtube video inside a floating popup window in android
body: <p>I can create a floating popup window using standout library <a href="https://github.com/pingpongboss/StandOut" rel="nofollow">https://github.com/pingpongboss/StandOut</a> . As I understand this library creates a service which creates a popup window. </p>
  
  <p>Youtube API for Android provides YouTubePlayerView, which can be only used with YoutubeBaseActivity, and which I cannot use because the floating popup window belongs to a service.</p>
  
  <p>Youtube API also provides YoutubePlayerFragment, which also cannot be used because services cannot work with fragments.</p>
  
  <p>There is also WebView, which can be used here, which is not as nice as Youtube API for Android, but better than nothing. It almost works for me. The WebView is displayed inside a floating popup window, and the video is being played, but the video is just black.</p>
  
  <p>Here is WebView code</p>
  
  <pre><code>    private static final String FRAME_VIDEO = "&lt;html&gt;&lt;body&gt;Video From YouTube&lt;br&gt;&lt;iframe width=\"320\" height=\"280\" src=\"https://www.youtube.com/embed/_oEA18Y8gM0\" frameborder=\"0\"&gt;&lt;/iframe&gt;&lt;/body&gt;&lt;/html&gt;";
  
  
      WebView webView = (WebView) findViewById(R.id.webView);
      webView.setWebViewClient(new WebViewClient(){
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
              return false;
          }
      });
      WebSettings webSettings = webView.getSettings();
      webSettings.setJavaScriptEnabled(true);
      webSettings.setPluginState(WebSettings.PluginState.ON);
      webView.setWebChromeClient(new WebChromeClient());
      webView.loadData(FRAME_VIDEO, "text/html", "utf-8");
  </code></pre>
  
  <p>Maybe one of these options is possible:</p>
  
  <ol>
  <li><p>Somehow use YoutubePlayerView without YouTubeBaseActivity</p></li>
  <li><p>Use fragments without activity</p></li>
  <li><p>Fix the WebView code</p></li>
  <li><p>Maybe there is some other way to play youtube videos inside a floating popup window</p></li>
  </ol>