I've been trying to get html5 video to play in webview. I actually got that to work but then I had orientation issues. I decided to let a media player handle the file so that it can take care of orientation etc. This seems to work great. However, I do I modify the code so that if a player isn't available it gives a toast and not cause my app to crash? any suggestions?
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().equals("my.site.com")) {
return false;
}else if(url.endsWith(".mp4")) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
intent.setDataAndType(Uri.parse(url), "video/*");
view.getContext().startActivity(intent);
return true;
}
// Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
}