unable to play youtube video on 2.3 - android

I'm unable to open you tube into my application's webview on android 2.3 but on android 4.1 it works properly
here is the code
openWebLinkWebView.getSettings().setJavaScriptEnabled(true);
openWebLinkWebView.getSettings().setBuiltInZoomControls(true);
openWebLinkWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
openWebLinkWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
openWebLinkWebView.getSettings().setAppCacheEnabled(false);
openWebLinkWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
openWebLinkWebView.getSettings().setLightTouchEnabled(false);
openWebLinkWebView.getSettings().setUseWideViewPort(true);
openWebLinkWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
openWebLinkWebView.getSettings().setPluginsEnabled (true);
openWebLinkWebView.getSettings().setSupportMultipleWindows(true);
openWebLinkWebView.getSettings().setPluginState(PluginState.ON);
openWebLinkWebView.loadUrl(url);

you can use this code in your YouTube video Activity class
WebView web=new WebView(MyYouTubeActivity.this);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("youtube_link");
setContentView(mWebView);

Yes i faced this issue before this is because the feature of android:hardwareAccelerated="true" is only available in API version greater or equal to 11 and in 4.1 it is by default enabled (you can enable/disable this in manifest at application level).

I had a problem like yours when playing on 2.3.3
The following worked for me.
webView = (WebView) findViewById(R.id.idWebView);
webView.setWebChromeClient(new WebChromeClient(){
});
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getTouchables();
webView.setBackgroundColor(Color.parseColor("#00000000"));
String emdLink = "http://www.youtube.com/embed/" + video_code;
webView.loadUrl(emdLink);
Note: you should have embed + your video code.
Note also the above uses a deprecated call - in place of
webView.getSettings().setPluginsEnabled(true);
it should be better to use (untested):
webView.getSettings().setPluginState(PluginState.ON);

Related

zoom is not working in webView on android application

When I open pptx file through this link zoom is not working in android webview.
Here is the code that i'm using:
WebSettings setting = wView.getSettings();
setting.setBuiltInZoomControls(true);
setting.setSupportZoom(true);
In the OnCreate method, just put
webView.getSettings().setBuiltInZoomControls(true);
And it's working fine here.
For enable zoom option add this line of code.
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);

Android Webview doesn't load

I have a problem with Android Web view.
The slider work fine with Apple but doesn't load on Android WebView.
Can anyone help? www.pgc-usa.net/ivynails
Thanks
I think I know. Web views in Android by default do not have JavaScript enabled. This is because there is someway it can do harm to the app. To enable it though it takes two lines
WebSettings webSettings = yourWebview.getSettings();
yourWebview.setJavaScriptEnabled(true);
You can also set it so that links that are clicked open in the web view. ( Otherwise they open in browser.) to add this you just add
yourWebview.setWebViewClient(new WebViewClient());
All that together will make it come to this:
WebView yourWebview = (WebView) findViewById(R.id.myWebview);
yourWebview.loadUrl("http://www.pgc-usa.net/ivynails");
WebSettings webSettings = yourWebviewgetSettings();
webSettings.setJavaScriptEnabled(true);
yourWebview.setWebViewClient(new WebViewClient());
You can find out more by visiting this page on the Android developer site by clicking this link.

How to run the HTML5 video in webview in android

From last one week i try to find how to play a html5 video in android webview i read so many blog and questions in the stack overflow but my problem is solve.i am using .mp4 , .wevm ,ogv and also .3gp format but noon of format is running.
i run these videos in the two different device one is micro-max funbook with android 4.0 and the another device is a Samsung device with 2.3.3 android os.
this is my code.
url="file://"+Environment.getExternalStorageDirectory()+"/unzipped/HTML5/res/test1.html";
webview = (WebView) findViewById(R.id.webview);
webview.setWebChromeClient(new WebChromeClient());
webview.getSettings().setPluginsEnabled(true);
webview.getSettings().setPluginState(PluginState.ON);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
webview.loadUrl(url);
For API level 11+ it should suffice that you add the attribute android:hardwareAccelerated="true" to the <application> tag in your Android manifest file.
For older APIs you need to implement the methods onShowCustomView and onHideCustomView in your your own WebChromeClient.
Or you can check out the html5webview

Video not appearing on a WebView

I has a app that loads a url on a WebView.
web = (WebView) findViewById(R.id.webview);
WebSettings settings = web.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
settings.setSupportMultipleWindows(false);
settings.setSupportZoom(false);
settings.setPluginsEnabled(true);
web.setVerticalScrollBarEnabled(false);
web.setHorizontalScrollBarEnabled(false);
web.loadUrl(lastUrl);
But a spot that should has Video first shows a "loading" view than disappears, if a tap on it occurs, the sound of the video starts playing but not show.
PS: I came across answers that told to add the hardwareAccelerated flag on Manifest, but this solutions simply does not work here.
I used settings.setDomStorageEnabled(true) as well with hardwareAccelerated="true" and it's working.
Did you see this question and the comment from slytron?
By the way setPluginsEnabled is deprecated in favor of setPluginState as of API level 8.

Webpage not available on Honeycomb webview

We have a webview that we are loading from android_assets. This works fine in 2.1, 2.2, and 2.3. However, when we load it in 3.0, we get a "Webpage not available" message.
This only happens on pages where we are passing parameters to the webview:
WebView webView = (WebView) findViewById(R.id.my_webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new JavaScriptInterface(this), "androidInterface");
webView.setBackgroundColor(0);
//This works
webView.loadUrl("file:///android_asset/my.html");
//This does not work.
webView.loadUrl("file:///android_asset/my.html" + "?param=value");
Any idea how to get this to work on Honeycomb?
Not answer to the original problem, but a workaround. Since I was already using the JavascriptInterface, I set the value that I wanted to read in Javascript on the JavascriptInterface.

Categories

Resources