1

I loaded the embedded youtube url into webview.But if i press play button its not perfoming any action but if i press somewhere other than play button the youtube video is getting played.Please some one help me.Thanks in advance.

HomeFragment.class:
public class HomeFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater,
    @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// TODO Auto-generated method stub
View rootView = inflater.inflate(R.layout.activity_main1, container,
        false);
WebView webview=(WebView)rootView.findViewById(R.id.webView1);
webview.loadUrl("https://www.youtube.com/embed/DXLnBMZM09g");
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {



    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);

        return true;
    }

    @Override
    public void onPageStarted(WebView view, String url,
            Bitmap favicon) {
        super.onPageStarted(view, url, favicon);

    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);

    }
     });


   return rootView;

    }
    }
   activity_main1:


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:hardwareAccelerated="true" >

<WebView
    android:id="@+id/webView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:focusable="true"
     android:layout_weight="1" />

Hema
  • 37
  • 9
  • I went through the exact problem not few hours back! Try to look at this link, maybe it will help. I was struggling with [iFrame embedded youtube playback](http://stackoverflow.com/questions/9036415/android-webview-cannot-render-youtube-video-embedded-via-iframe). – Antrromet Oct 03 '14 at 15:48
  • Actually my video is playing..Problem is if I press play button its not getting played..If I press somewhere in activity other than play button its getting played..I don't no what is the reason.. – Hema Oct 03 '14 at 18:40

1 Answers1

0

I had the same problem few days ago, but now, video is playing as expected when play button is pressed. I guess it was a bug on Youtube's side...

Bertrand
  • 123
  • 6