I’m developing a news reader app, so I parse RSS feed data and then populate android components. There, I have a WebView component which displays HTML data (parsed from specific XML tag, but it is not important).
So, that HTML data contain valid HTML, with text, formatting, images, and in some news – can contain embedded videos.
Videos are embedded through an (YT), (other video hosting sites) and are displayed/played correctly – web view plays it in-place. Videos are from YouTube, Vimeo, etc. but mainly (>90%) from YouTube, so YouTube is a scope of this question.
I use following code to display webview content:
webContent.setWebViewClient(new WebViewOverrideUrl());
webContent.getSettings().setJavaScriptEnabled(true);
webContent.getSettings().setPluginsEnabled(true);
webContent.loadDataWithBaseURL(null, htmlContent.toString(), "text/html", "utf-8", null);
My questions are:
1. Is there a possibility to redirect this video to a standalone app, i.e. YouTube or Flash player (or whatever user have installed to play videos)?
I have read so many posts regarding this topic but i can’t find a solution. Not even a clue.
2. Is it possible to tell that frame with video (mostly YouTube) content to play it in fullscreen when change orientation to landscape (Or if it is in landscape already, to play it in fullscreen immediately when clicked)?
3. Is it even possible with YouTube (Flash) player, and if it’s not, is it possible with HTML5 tag (instead of the iframe)?
There is a possibillity to create any tab for video and embed it in HTML contents on server side (, , , <…whatever…>), so i am looking for possible options.
Thanks a lot in advance, if I come up with some kind of solution in meantime, I will definitely post it here. A lot of people face the similar problems.
Well, to answer this question, at last.
Because of a very large number of different devices and different Android systems on those devices, i decided to use the simplest approach – I just ask user where he wants to play video.
The code that everyone knows is:
Since i was getting youTube link in an embedded tag, guy who creates XML data for me, made a regex which gets youTube link only and i wrapped it in html tags, partly on server, and partly inside app to get acceptable appearance.
This was the only way i found that works on every device. Tried to aim YouTube app directly, but that didn’t work on some very common devices that even have YT installed (Telenor/Alcatel OneTouch). Tried and succeeded in creating custom video player, but it didn’t work on some random devices, although it worked on different pieces of a same device model.
Hope this can help someone.