I want to play embedded videos (not youtube videos) in my android app. I know how to use iframe but i dont get options fo seek to skip. Is there any library for that to play iframe videos easily in android app?
This works for me
webviewWebView = (WebView) findViewById(R.id.webview_web_view);
webviewWebView.setWebChromeClient(new WebChromeClient());
webviewWebView.getSettings().setPluginState(WebSettings.PluginState.ON_DEMAND);
webviewWebView.getSettings().setJavaScriptEnabled(true);
String customHtml = "<iframe width=\"380\" height=\"315\" src=\"https://www.youtube.com/embed/videoseries?list=PLBRur06WH1SlYw3rIr051vPw442oBB50e\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>";
webviewWebView.loadData(customHtml, "text/html", "UTF-8");
I have a problem when load html5 into webview.
My app in first build play video success but when i clear/kill app open again, webview not play video when click play.
Html5
<video src="url.mp4" controls poster="thumbnail.jpg" style="max-width: 100%;">Download video</video>
Source load webview
WebView webView = new WebView(context);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient());
String html = "<html><head><link rel='stylesheet' href='file:///android_asset/css/style.css'></head><body>"
+ htmlElement.getContent()
+ "</body></html>";
webView.loadDataWithBaseURL("file:///android_asset/", html, mimetype, encoding, "");
I research and try fix this issue but not success
https://stackoverflow.com/questions/3815090/webview-and-html5-video
https://issuetracker.google.com/issues/36935939 v.v..
Anyone has the same my problem? Thanks.
Try this :-
DashBoardFragment2.java :-
https://drive.google.com/file/d/1UREa7uGrQYcF-ABzPktBSjUcOPtytxSC/view?usp=sharing
dashboard.xml :-
https://drive.google.com/file/d/1LlgbdSe-9bgUU5lsGZUGOX3Tg7bnVpzH/view?usp=sharing
No doubt this question was answered many times over the stackover flow and on many other sites. I have tried the all possible solutions but my problem is still there. Kindly can you please figure out the problem and how I fix it
I want to load SWF file that contain animation in android activity. But problem it this. It didn't show any output
Look at this image
This is my code
WebView mWebView;
mWebView = (WebView) findViewById(R.id.webview);
String html = "<object width=\"200\" height=\"200\"> <param name=\"movie\" value=\"file:///android_res/raw/ttl_logo_animate.swf\"> <embed src=\"file:///android_res/raw/ttl_logo_animate.swf\" width=\"200\" height=\"200\"> </embed> </object>";
String mimeType = "text/html";
String encoding = "utf-8";
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
mWebView.setBackgroundColor(Color.parseColor("#ffffff"));
mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.loadDataWithBaseURL("null", html, mimeType, encoding, "");
Any one can figure out the problem..?
SDK Versions
android:minSdkVersion="11"
android:targetSdkVersion="12"
I need to embed a youtube video on my app, possibly showing the video while i am in the app and not using youtube app. I am able to do that using webview and the iframe embed thing in youtube video, and it works fine on 2 of my devices: one has Android 4.1.1, the other 4.2.
It doesen't work when i try on my phone with Android 2.3.4: it shows the thumbnail but when i click on it just remains a black space.
Maybe Android versions < 3.0 doesen't support HTML5 tags?
Sorry i am relatively new to this thing. Thanks in advance.
Here is my code:
wbv = (WebView) this.findViewById(R.id.webView1);
wbv.setFocusable(true);
wbv.setFocusableInTouchMode(true);
wbv.getSettings().setJavaScriptEnabled(true);
wbv.getSettings().setPluginState(PluginState.ON);
wbv.getSettings().setRenderPriority(RenderPriority.HIGH);
wbv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
wbv.getSettings().setDomStorageEnabled(true);
wbv.getSettings().setDatabaseEnabled(true);
wbv.getSettings().setAppCacheEnabled(true);
wbv.setWebViewClient(new WebViewClient());
wbv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
String html ="<html><body><iframe class=\"youtube-player\" type=\"text/html\" width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/ID\" frameborder=\"0\" allowfullscreen></iframe></body></html>";
String mime = "text/html";
String encoding = "utf-8";
wbv.loadData(html, mime, encoding);
as for me it works in following way:
final WebSettings settings = webView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
settings.setJavaScriptEnabled(true);
settings.setLoadsImagesAutomatically(true);
settings.setPluginsEnabled(true);
//settings.setPluginState(PluginState.ON);
webView.loadUrl("http://www.youtube.com/embed/"+videoClip.youtubeId);
using aos 2.3.4 device. I also work if use your way, I mean IFrame:
final String sUrl = "http://youtube.com/embed/"+videoClip.youtubeId;
final String html ="<html><body><iframe class=\"youtube-player\" type=\"text/html\" width=\"560\" height=\"315\" src=\""+sUrl+"\" frameborder=\"0\" allowfullscreen></iframe></body></html>";
webView.loadData(html, "text/html", "utf-8");
however I confirm that both methods doesn't work on my froyo (2.2.2) aos device. It swows some blue chip for a seconds and thats all. It stays with black screen or frame.
I am new to android. I am facing two problems right now 1. I parsed xml file and showed it in webview which contains videos and text . When i click on videos it will not play . In xml videos are youtube embed.
Why is it so?
1.First problem :code and image
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web_view);
Intent intent=getIntent();
String urlsting=intent.getStringExtra("str");
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.setInitialScale(100);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.loadDataWithBaseURL(null, urlsting,"text/html", "utf-8", null);
}
When i clcik on video it starts browsing and shows only black screen,then nothing will happen.
![][1]
2. I have you-tube embedded videos url which I given in html tag and try to load it .They are also not working for me. I checked number of questions and blogs and also made no of settings then also unable to show video . Help will be appreciated .Thanks in advance.
String video= "<table bgcolor=\"#666666\"><tr><td><iframe width=\"300\" height=\"260\" frameborder=\"0\" id=\"player\" type=\"text/html\"src=\"http://www.youtube.com/embed/iiLepwjBhZE?enablejsapi=1&origin=example.com\"></iframe></td></tr><tr><td><iframe width=\"300\" height=\"260\" frameborder=\"0\" id=\"player\" type=\"text/html\"src=\"http://www.youtube.com/embed/lBMMTeuJ_UQ?enablejsapi=1&origin=example.com\"></iframe></td></tr><tr><td><iframe width=\"300\" height=\"260\" frameborder=\"0\" id=\"player\" type=\"text/html\"src=\"http://www.youtube.com/embed/BZMkY3y7nM0?enablejsapi=1&origin=example.com\"></iframe></td></tr><tr><td></table>";
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.getSettings().setPluginsEnabled(true);
//mWebView.loadDataWithBaseURL(null,load,"text/html","UTF-8",null);
mWebView.loadData(video,"text/html","UTF-8");
In this case I load the youtube embeded videos to webview but they are also not working.
![][2]
I am using android 2.3.3version.I also want clarification that is there any requirement of install adobe flash player on emulator, but i think no because videos are working in browser. can anybody tell i am right or wrong?? please try to give me solution because i stuck with this problem long ago..
I also tried using object tag as follows:
String obj="<object width=\"300\" height=\"260\"><param name=\"movie\" value=\"http://www.youtube.com/embed/iiLepwjBhZE?enablejsapi=1&origin=example.com\"?version=3&hl=pt_BR&rel=0\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/embed/iiLepwjBhZE?enablejsapi=1&origin=example.com\" ?version=3&hl=pt_BR&rel=0\" type=\"application/x-shockwave-flash\" width=\"480\" height=\"330\" allowscriptaccess=\"always\" allowfullscreen=\"true\" /></object>";
You need to
set a WebChromeClient to your WebView
web.setWebChromeClient(new WebChromeClient());
and turn on hardwareAccelerated value
<application
android:hardwareAccelerated="true"...
check out http://developer.android.com/reference/android/webkit/WebView.html and read HTML5 Video support part.
This works for me...
I guess, you are using iframe tag in your html code. Change it with object tag. I mean, you must use object instead iframe. An example here:
<object width="480" height="330"><param name="movie"
value="http://www.youtube.com/v/"here is your video id"?version=3&hl=pt_BR&rel=0">
</param><param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/"here is your video id"?version=3&hl=pt_BR&rel=0"
type="application/x-shockwave-flash" width="480" height="330" allowscriptaccess="always" allowfullscreen="true" /></object>
Use the code below:
webview.getSettings().setPluginsEnabled(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setAllowFileAccess(true);
webview.loadUrl(url);
Try this and thick it as accepted if your problem solved :)
have you tested your app in actual device? Because the videos which are embedded like this i.e. iFrame are taking more time to get loaded. In my case, same thing was happening then I changed the webview settings to,
getSettings().setPluginsEnabled(true);
but after that it was not working on emulator and in device it was loading so I thought its not working but just today I tried the same thing and it was working fine with my surprise. So you just need to add this line of code.
Second thing is that only those videos which are embedded in iframe tag are supported by enabling plugins to true.
This does it:
myWebView.getSettings().setPluginState(PluginState.ON);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setAllowFileAccess(true);
myWebView.setWebChromeClient(new WebChromeClient());
And enable hardware acceleration too!
Follow this source, Youtube video should play
String youtubeId = "iiLepwjBhZE";
int width = rl.getWidth();
int height = rl.getHeight();
WebChromeClient mWebChromeClient = new WebChromeClient(){
public void onProgressChanged(WebView view, int newProgress) {
/*
view.loadUrl("javascript:(function() { " +
"document.querySelector('iframe').setAttribute('style', 'width: 1080px; height: 1920px'); " +
"})()");
*/
}
};
String video= "<table bgcolor=\"#666666\"><tr><td><iframe width=\"" +
width +
"\" height=\"" +
height +
"\"frameborder=\"0\" id=\"player\" type=\"text/html\"src=\"http://www.youtube.com/embed/" +
youtubeId +
"?enablejsapi=1&origin=example.com\"></iframe> </td> </tr><tr><td></table>";
//
webView.getSettings().setPluginState(PluginState.ON);
webView.setWebChromeClient(mWebChromeClient);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.setInitialScale(1);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
//mWebView.loadDataWithBaseURL(null,load,"text/html","UTF-8",null);
webView.loadData(video,"text/html","UTF-8");