Hello,
I'm trying to play a Youtube video embedded in my app layout.
I thought it would be easy, but apparently it's not (for me).
I tried with VideoView and a RTSP link but the quality is too bad.
I also tried with a WebView but it doesn't work on some Android versions.
I'd like to support Android 2.x if possible.
On Android 2.3, I have player buttons but the video does not start.
On Android 2.1, when I tap the play button, I have a message "An error 
occurred, please try again later."
I also want to support platforms without the Youtube app (like Amazon, 
Blackberry...) so the Youtube Android Player API is not an option for me.
Please help... Thanks in advance!

Here is my code:

public class YoutubeActivity extends Activity {
  private WebView webView;
  public void onCreate (Bundle savedInstanceState) {
    super.onCreate (savedInstanceState);
    webView = new WebView (this);
    setContentView (webView);
    webView.getSettings ().setJavaScriptEnabled (true);
    webView.setWebChromeClient (new WebChromeClient ());
    webView.setWebViewClient (new WebViewClient () {
      public boolean shouldOverrideUrlLoading (WebView view, String url) {
        view.loadUrl (url);
        return true;
      }
    });
    if (Build.VERSION.SDK_INT < 8) {
      webView.getSettings ().setPluginsEnabled (true);
    }
    else {
      webView.getSettings ().setPluginState (PluginState.ON);
    }
    webView.loadUrl ("http://youtube.com/embed/sNUNB6CMnE8?rel=0";);
  }
  protected void onPause () {
    super.onPause ();
    webView.loadUrl ("about:blank");
  }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to