• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Use Youtube player Api with android Fragment

krishnaveni

Well-Known Member
Dec 16, 2011
158
0
chennai
I have to develop an android application, I am using a fragment and the youtube player API. I have added YouTubeFailureRecoveryActivity and I am getting the error bellow:

Syntax error, insert "ClassBody" to complete ClassDeclaration

I have used this code:
HTML:
  public class SubCate extends  Fragment
  {     
     TextView lblName;
     String _Title,_Video;

      WebView fullcontent;
     YouTubePlayerView youTubeView;
    @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  }     

    @Override
 public View onCreateView(LayoutInflater inflater, ViewGroup container, 
    Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.subcate,
            container, false);

    lblName = (TextView) view.findViewById(R.id.title);
    fullcontent = (WebView) view.findViewById(R.id.fullcontent);
    youTubeView = (YouTubePlayerView) view.findViewById(R.id.youtube_view);
          youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, getActivity());
    Bundle bundle = getArguments();


    return view;

        }



         public void updateDetail(String articletitle,String articlefullcontent,String articlevideo) {

            _Title = articletitle.substring(1);
          lblName.setText(_Title);

            _Video = articlevideo.substring(1);

            }
            public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
          boolean wasRestored) {
        if (!wasRestored) {

          player.cueVideo(_Video);

        }
              }

              protected YouTubePlayer.Provider getYouTubePlayerProvider() {
        return youTubeView;

                  } 
        }


I have removed YouTubeFailureRecoveryActivity class from my extending class.

Now I am getting an error on this line:

HTML:
youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, getActivity());

The error is :

The method initialize(String, YouTubePlayer.OnInitializedListener) in the type YouTubePlayerView is not applicable for the arguments (String, Activity)

What's wrong in my code? Why am getting I this error? How can I clear this error? Please give me solution for this.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones