0
我知道這個問題被問了很多次,但沒有解決方案工作。我想要做的是非常簡單的。我有一個url,我想加載網址在WebView
。該網址包含videos.Bt,而點擊播放按鈕時,它不會播放任何內容。Android WebView不能播放Youtube視頻點擊
以下是我的代碼,我到目前爲止已經試過,
public class MoviesActivity extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Adds Progrss bar Support
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.webview);
// Makes Progress bar Visible
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
// Get Web view
mWebView = (WebView) findViewById(R.id.webView1); //This is the id you gave
if (Build.VERSION.SDK_INT < 8) {
mWebView.getSettings().setPluginsEnabled(true);
} else {
mWebView.getSettings().setPluginState(PluginState.ON);
}
//to the WebView in the main.xml
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(true); //Zoom Control on web (You don't need this
// mWebView.getSettings().setPluginsEnabled(true); //if ROM supports Multi-Touch
mWebView.getSettings().setBuiltInZoomControls(true); //Enable Multitouch if supported by ROM
// Load URL
// Sets the Chrome Client, and defines the onProgressChanged
// This makes the Progress bar be updated.
final Activity MyActivity = this;
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
MyActivity.setTitle(R.string.app_name);
}
});
mWebView.setWebViewClient(new HelloWebViewClient());
mWebView.loadUrl("http://www.youtube.com/user/africanmoviesnews");
mWebView.setWebViewClient(new HelloWebViewClient());
}//End of Method onCreate
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
感謝您的回覆Ram。但我有一個網站鏈接不是一個視頻。檢查此URL「http://www.youtube.com/user/africanmoviesnews」。希望我清楚。 –