Flash en webview Android, videos youtube
I am trying to show videos of youtube in the webview for Android. I use this code:
var webview = Titanium.UI.createWebView({
top:45,
left:0,
height:360,
width:320});
var entryVideo = 'http://www.youtube.com/v/???????';
var html = '<html><body><div><embed id="yt" src="'+entryVideo+'" type="application/x-shockwave-flash" width="300" height="150"></embed></div></body></html>';
webview.html = html;
However, nothing is shown, the webview is empty, unlike the iPhone, where the same code works fine (shows a preview image of the video).
I have found out, that <b> in Java </b> it is necessary to call getSettings().setPluginsEnabled(true)
for the WebView class, to enable plugins como Flash.
It is similar to calling <b> in Java </b> getSettings().setJavaScriptEnabled(true)
to enable Javascript.
I found the source code of Appcelerator here:
http://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/ti/modules/titanium/ui/widget/webview/TiUIWebView.java
I see, that setJavaScriptEnabled(true)
is called, but setPluginsEnabled(true)
is NOT called. Seems like plugins are not enabled for the implementation of WebView for Android.
Is it true? Is it intentional or is it a bug?
How can I show the videos of Youtube on android in this case?
8 Answers
-
Well, it's my other incarnation with a different email. I finally ended up using YouTube player, it does work if u use OpenURL and URL like their urls, http://www.youtube.com/watch?v=…
The Appcelerator people are unsure, if they should enable plugins, because many older Android phones are not flash-enabled (they use something like Flash Lite)
I would say, they should, at least give an option in the property list of webview.
-
We need to have option to enable plugins especially flash appcelerator please
-
This issue is still appearing with mobileSDK 1.8 nightly build. One workaround I found was to use
Titanium.Platform.openURL('http://your.url/');
to open the page in the native browser, but this does not share session data with in app webviews, and it opens on top of instead of inside of your app.I'm going to try writing a module to extend the Titanium webview to add
setPluginsEnabled(true)
to the webview setup code and report results. -
If you need a flash plugin (or other plugins) in your webview then go to githbu download the newest titanium_mobile_sdk and make changes in the java source for android SDK. Use google like "android webview setPlugins(1)" I think there is a guide on stackoverflow
-
Hi Tom Ferch,
Dear friend,, we saw your comment on flash in Android webview. will u please explain detail how to achieve this. we are using Titanium to develop native application for Samsung galaxy tab.
Pls help in this matter, thanks in advance.
Regards
Vinod Varghese -
Hi Tom Ferch,
I find your answer here. But I don't know how to do it, because I a beginner to appcelerator.
Please please please if you explain it in some more detail, it will be very helpful for me.
-
TIMOB-1607 is in CI 1.8.0. There is example code in the JIRA issue.
-