-7

I want to play YouTube videos inside my android app. How can I do it without downloading the YouTube API? I found the following code here on stack overflow:

new Thread(new Runnable() {
            @Override
            public void run() {
                final WebView myWebView = (WebView) findViewById(R.id.webView1);
                myWebView.setWebViewClient(new WebViewClient());
                myWebView.getSettings().setJavaScriptEnabled(true);
                myWebView.setWebChromeClient(new WebChromeClient());

                try {
                    Log.e("Status", "tried url");
                    myWebView.loadUrl(icobj.video_URL);  

                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Log.e("Status", "In Run():");
                        }
                    });

                } catch (Exception e) {
                    e.printStackTrace();
                    Log.e("Status", "exception");
                }       
            }       
        }).start();

But "handler cannot be resolved to a variable" error is shown. Please help!!

Community
  • 1
  • 1
user3852672
  • 285
  • 1
  • 8
  • 17
  • 1
    Firstly, please show us your efforts (not someone elses). Secondly, have a look at http://stackoverflow.com/a/11551203/3436942 or read the docs: http://developer.android.com/guide/topics/media/mediaplayer.html – jbutler483 Aug 26 '14 at 10:38

1 Answers1

-1

with a quick view at your code, I would suggest that you should check which type of variable the handler is and whether you have imported and created it.

If that does not work, you could have a look at the exo player from google , which I am using for my video related projects.

grishnagkh
  • 49
  • 4