I am trying to get an HTML 5 video to play using WebView, but I keep getting this error:
“CustomViewCallback cannot be resolved to a type”
Here is the code:
myWebView.setWebChromeClient(new WebChromeClient() {
public void onShowCustomView(View view, CustomViewCallback callback) {
super.onShowCustomView(view, callback);
if (view instanceof FrameLayout){
FrameLayout frame = (FrameLayout) view;
if (frame.getFocusedChild() instanceof VideoView){
VideoView video = (VideoView) frame.getFocusedChild();
frame.removeView(video);
setContentView(video);
video.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
setContentView(R.layout.mnwv_main);
}
});
video.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
return false;
}
});
video.start();
}
}
}
}); // new WebChromeClient() ends...
myWebView.loadUrl("http://www.meanwhileinwv.com");
}
Anyone know what I could do?
WebChromeClient.CustomViewCallbackis supported since API Level 7 (2.1). So my guess your testing device (or simulator) has lower API level.