title: How to play HLS video in Android?
body: <p>Here is stream video from justin.com or <a href="http://twitch.tv" rel="nofollow noreferrer">twitch.tv</a> this <a href="http://www.twitch.tv/synderen" rel="nofollow noreferrer">CHANNEL</a><br />
  Go to <a href="http://www.twitch.tv/directory/game/Dota%202/live" rel="nofollow noreferrer">here</a> and choose any live stream, get from them url and add html://.../hls
  in screen appears<br />
  <img src="https://i.stack.imgur.com/4DI4Q.png" alt="enter image description here" /></p>
  <p>Guys told me that:</p>
  <blockquote>
  <p>Android is weird in that it will not work on Android Chrome but will
  work in the stock Android browser (well, previous stock Android
  browser now that Chrome is the stock browser). It'll also work on all
  Safari browsers.</p>
  </blockquote>
  <p>I've implemented this code</p>
  <pre class="lang-java prettyprint-override"><code>stream = (WebView) findViewById(R.id.webView1);
  stream.getSettings().setJavaScriptEnabled(true);
  stream.getSettings().setPluginsEnabled(true);
  stream.setBackgroundColor(Color.parseColor(&quot;#000000&quot;));
  stream.getSettings().setUseWideViewPort(true);
  stream.setWebViewClient(new HelloWebViewClient());
  stream.getSettings().setAppCacheEnabled(true);
  stream.getSettings().setDomStorageEnabled(true);
  stream.getSettings().setSaveFormData(true);
  stream.getSettings().setLoadWithOverviewMode(true);
  stream.getSettings().setUseWideViewPort(true);
  stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  stream.setScrollbarFadingEnabled(false);
  stream.loadUrl(&quot;http://www.twitch.tv/arteezy/hls&quot;);
  stream.setVisibility(View.VISIBLE);
  
  private class HelloWebViewClient extends WebViewClient 
  {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) 
      {
          view.loadUrl(url);
          return true;
      }
  }
  </code></pre>
  <p><strong>But it opens first picture from video and stop caching... it seems like WebView doesn't cache video...</strong>
  What is wrong?</p>
  <p><strong>UPDATED</strong></p>
  <p>after following code stream plays only 2 sec and then stops</p>
  <pre class="lang-java prettyprint-override"><code>stream = (WebView) findViewById(R.id.webView1);
  stream.getSettings().setJavaScriptEnabled(true);
  stream.getSettings().setJavaScriptEnabled(true);
  
  stream.getSettings().setPluginsEnabled(true);
  
  stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  
  stream.setBackgroundColor(Color.parseColor(&quot;#000000&quot;));
  stream.getSettings().setUseWideViewPort(true);
  // mWebView.loadUrl(&quot;data/game.swf&quot;);
  //mWebViewChat.getSettings().setBuiltInZoomControls(true);
  // mWebView.loadUrl(&quot;file:///android_asset/live.swf?channel=d2l&quot;);
  stream.setWebViewClient(new HelloWebViewClient());
  final Activity MyActivity = this;
  stream.setWebChromeClient(new WebChromeClient() {
      public void onProgressChanged(WebView view, int progress)   
      {
          MyActivity.setTitle(&quot;Loading...&quot;);
          MyActivity.setProgress(progress * 100); 
          if (progress*100 == 100){
              stream.clearFormData();
              stream.clearHistory();
              stream.clearCache(true);
          }
  
      }
  });
  stream.getSettings().setAppCacheEnabled(true);
  stream.getSettings().setDomStorageEnabled(true);
  stream.getSettings().setSaveFormData(true);
  
  stream.getSettings().setLoadWithOverviewMode(true);
  stream.getSettings().setUseWideViewPort(true);
  
  stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  stream.setScrollbarFadingEnabled(false);
  stream.clearFormData();
  stream.clearHistory();
  stream.clearCache(true);
  
  stream.getSettings().setAppCacheEnabled(true);
  stream.getSettings().setDatabaseEnabled(true);
  stream.getSettings().setDomStorageEnabled(true);
  stream.getSettings().setPluginsEnabled(true);
  
  stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  stream.getSettings().setPluginState(PluginState.ON);
  stream.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// no need I think
  
  stream.getSettings().setLoadWithOverviewMode(true);
  stream.getSettings().setUseWideViewPort(true);
  stream.getSettings().setBuiltInZoomControls(true);
  stream.setInitialScale(1);
  
  stream.setWebChromeClient(new WebChromeClient());
  stream.getSettings().setJavaScriptEnabled(true);
  
  stream.getSettings().setPluginsEnabled(true);
  
  stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  
  stream.setBackgroundColor(Color.parseColor(&quot;#000000&quot;));
  stream.getSettings().setUseWideViewPort(true);
  // mWebView.loadUrl(&quot;data/game.swf&quot;);
  //mWebViewChat.getSettings().setBuiltInZoomControls(true);
  // mWebView.loadUrl(&quot;file:///android_asset/live.swf?channel=d2l&quot;);
  stream.setWebViewClient(new HelloWebViewClient());
  stream.getSettings().setAppCacheEnabled(true);
  stream.getSettings().setDomStorageEnabled(true);
  stream.getSettings().setSaveFormData(true);
  
  stream.getSettings().setLoadWithOverviewMode(true);
  stream.getSettings().setUseWideViewPort(true);
  
  stream.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  stream.setScrollbarFadingEnabled(false);
  stream.clearFormData();
  stream.clearHistory();
  stream.clearCache(true);
  
  stream.getSettings().setAppCacheEnabled(true);
  stream.getSettings().setDatabaseEnabled(true);
  stream.getSettings().setDomStorageEnabled(true);
  stream.loadUrl(&quot;http://www.twitch.tv/arteezy/hls&quot;);
  </code></pre>