title: Getting a null pointer exception in WebView on loading a webpage with embedded video
body: <p>I am opening a webpage in WebView. The webpage contains an iframe which has an embedded video in it. I cannot post the webpage link, so posting its code.</p>
  
  <p>Code of webpage:</p>
  
  <pre><code>&lt;html&gt; 
  &lt;link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"  media="all" rel="stylesheet" type="text/css" /&gt;
  &lt;body&gt;
  &lt;div id="here"&gt;
  &lt;div class="embed-responsive embed-responsive-16by9"&gt;
  &lt;iframe id="video" class="class="embed-responsive-item" src="https://player.vimeo.com/video/129955969?title=0&amp;amp;byline=0&amp;amp;portrait=0&amp;amp;color=f2f2ea&amp;amp;autoplay=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;
  &lt;/div
  &lt;p style="color:#167AD0;"&gt;&lt;a href="#" &gt;Algebra - Progressions&lt;/a&gt;&lt;/p&gt;
  &lt;p style="color:#7E8394;"&gt;Bulls Eye Knowledge (P) Ltd.&lt;br/&gt;2 months ago * 1 views&lt;br/&gt;&lt;/p&gt;
  &lt;p style="border-top: 1px solid #7e8394;color: #7e8394;margin: 10px 0 0;padding: 0;"&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Android activity code:</p>
  
  <pre><code>public class WebPlayerActivity extends Activity {
  
  public static final String INTENT_EXTRA = "intent_extra";
  public static final String INTENT_EXTRA_TITLE = "intent_extra_title";
  
  private WebView webView;
  
  @Override
  public void onResume() {
      super.onResume();
      if (Build.VERSION.SDK_INT &gt;= 11)
          webView.onResume();
  }
  
  @Override
  public void onPause() {
      super.onPause();
      if (Build.VERSION.SDK_INT &gt;= 11)
          webView.onPause();
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.activity_web_view);
      TextView title = (TextView) findViewById(R.id.title);
      ImageView back = (ImageView) findViewById(R.id.back);
      webView = (WebView) findViewById(R.id.web_view);
      title.setText(getIntent().getStringExtra(INTENT_EXTRA_TITLE));
      back.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              finish();
          }
      });
      webView.getSettings().setPluginState(WebSettings.PluginState.ON);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.getSettings().setBuiltInZoomControls(true);
      webView.setWebChromeClient(new WebChromeClient());
      webView.loadUrl(getIntent().getStringExtra(INTENT_EXTRA));
  }
  
  @Override
  protected void onDestroy() {
      super.onDestroy();
      webView.loadUrl("about:blank");
  }
  }
  </code></pre>
  
  <p>The view opens fine at the beginning, but when I click on play, sometimes it gives me the following crash in my samsung tablet (Android version: 4.2.2), and sometimes the audio is running fine, but the video is not getting displayed, only black screen.</p>
  
  <p>Crash:</p>
  
  <pre><code>java.lang.NullPointerException
     at android.webkit.HTML5VideoView.reprepareData(HTML5VideoView.java:346)
     at android.webkit.HTML5VideoViewProxy$VideoPlayer.play(HTML5VideoViewProxy.java:245)
     at android.webkit.HTML5VideoViewProxy.handleMessage(HTML5VideoViewProxy.java:447)
     at android.os.Handler.dispatchMessage(Handler.java:99)
     at android.os.Looper.loop(Looper.java:176)
     at android.app.ActivityThread.main(ActivityThread.java:5365)
     at java.lang.reflect.Method.invokeNative(Method.java)
     at java.lang.reflect.Method.invoke(Method.java:511)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
     at dalvik.system.NativeStart.main(NativeStart.java)
  </code></pre>
  
  <p>Any ideas? I also have android:hardwareAccelerated="true" in my application tag in manifest.</p>
  
  <p>P.S. working fine in my nexus 5 and motorola device with lollipop version.</p>