1

I am trying to build an app with a webview on it that allows youtube playback . Right now the site of youtube is loading and i can click on the video but all I can hear is the sound of it and can't see anything .Would really be grateful for some help on the issue. The app is loaded on samsung galaxy s . sdk version 8.

import com.keyes.youtube.OpenYouTubePlayerActivity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

public class Youtube extends Activity {

private WebView mWebView;
private String extra;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);       

extra = getIntent().getStringExtra("VideosId");        
mWebView = (WebView) findViewById(R.id.webView1); 
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(PluginState.ON);
mWebView.getSettings().setLoadWithOverviewMode(true);// completely zoomed out
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getTouchables();



final Activity activity = this;
mWebView.setWebChromeClient(new WebChromeClient() {
  public void onProgressChanged(WebView view, int progress) {
    // Activities and WebViews measure progress with different scales.
    // The progress meter will automatically disappear when we reach 100%
    activity.setProgress(progress * 1000);
  }
});

mWebView.setWebViewClient(new ourViewClient());   


mWebView.loadUrl("http://www.youtube.com/watch?v=AIbHWcko0Mg&feature=g-all-bul");     
mWebView.setWebViewClient(new ourViewClient());      
}


@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
    mWebView.goBack();
    return true;
}
return super.onKeyDown(keyCode, event);
}
}
SurinderBhomra
  • 2,169
  • 2
  • 24
  • 49

1 Answers1

4

OK so it's quit sad but no one answered my question :( But I managed to figured it out by myself :

the API should be at least 11 (android 3.0 ) and in the manifest within the application definitions should go the following code : android:hardwareAccelerated="true" . enjoy !

  • 1
    you mean the code you you given will not work on API less than 11 ? i want to load youtube video on Api8 [My Question](http://stackoverflow.com/questions/14156411/loading-youtube-video-through-i-frame-in-android-webview) can you have look on this – edwin Jan 05 '13 at 11:00