I want to play video url inside my application webview but when i am run the application it showing only white screen . i had read some post on this and i have used that cod
I know this is an old issue, I had the same problem some days back and surfing across internet I found this complete source that helped me a lot, and now i want to share with others, maybe can help others like me..
https://github.com/cprcrack/VideoEnabledWebView
I also got stuck with this issue. I got correct response from server, but couldn`t play video. After long time I found a solution here. Maybe, in future this link will be invalid. So, here is my correct code
Uri video = Uri.parse("Your link should be in this place ");
mVideoView.setVideoURI(video);
mVideoView.setZOrderOnTop(true); //Very important line, add it to Your code
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// here write another part of code, which provides starting the video
}}
If tried others anwsers no work,maybe you can try this:
if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.LOLLIPOP){
webview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
Add webview.setWebChromeClient(new WebChromeClient());
and to enable plugins for your video add:
if (Build.VERSION.SDK_INT < 8) {
webview.getSettings().setPluginsEnabled(true);
}
else {
webview.getSettings().setPluginState(PluginState.ON);
}
Hope this helps.