How to embed a video from youtube or yahoo videos to an android application I'm using Phonegap so mainly I'm writing javascript then the code is wrapped to be n开发者_如何学Pythonative code
But I'm only writing JS & HTML5
You most likely want to use a WebView with the link pointed at the embedded video hyperlink.
Something along the lines of the following:
<LinearLayout ... >
... my content
<WebView android:id="@+id/webView1" ... >
...
</WebView>
</LinearLayout>
Then use the following hook in the code (mostly from the WebView docs):
WebView webview = (WebView) activity.getViewById(R.id.webView1);
// Simplest usage: note that an exception will NOT be thrown
// if there is an error loading this page (see below).
webview.loadUrl("http://slashdot.org/");
// OR, you can also load from an HTML string:
String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", "utf-8");
// ... although note that there are restrictions on what this HTML can do.
// See the JavaDocs for loadData() and loadDataWithBaseURL() for more info.
Don't forget
<uses-permission android:name="android.permission.INTERNET" />
in the manifest.
精彩评论