0

Hi I want to play YouTube videos in my application and I am Using THIS LIBRARY . I am initializing all values inside Adapter so I can't `extend YouTubeBaseActivity class. Please tel me a good way to achieve my goal. Just like other app, I also want to play youtube videos inside application,. Here is my adapter code

 Pattern compiledPattern = Pattern.compile(pattern);
                Matcher matcher = compiledPattern.matcher(thumbanil_url);
                if (matcher.find()) {
                    value_id = matcher.group();
                    ((DemoViewHolderThird) holder).demoThirdItemInitView.youtubePlayerView.setAutoPlayerHeight(context);
                    ((DemoViewHolderThird) holder).demoThirdItemInitView.youtubePlayerView.initialize(value_id, new YoutubePlayerView.YouTubeListener() {


                        @Override
                        public void onReady() {
                            ((DemoViewHolderThird) holder).demoThirdItemInitView.youtubePlayerView.play();
                            JLog.i("onReady()");
                        }

                        @Override
                        public void onStateChange(YoutubePlayerView.STATE state) {
                           // ((DemoViewHolderThird) holder).demoThirdItemInitView.youtubePlayerView.play();
                        }

                        @Override
                        public void onPlaybackQualityChange(String arg) {
                            //((DemoViewHolderThird) holder).demoThirdItemInitView.youtubePlayerView.play();
                        }

                        @Override
                        public void onPlaybackRateChange(String arg) {
                            //((DemoViewHolderThird) holder).demoThirdItemInitView.youtubePlayerView.play();
                        }

                        @Override
                        public void onError(String arg) {
                            //((DemoViewHolderThird) holder).demoThirdItemInitView.youtubePlayerView.play();
                        }

                        @Override
                        public void onApiChange(String arg) {
                        }

                        @Override
                        public void onCurrentSecond(double second) {

                        }

                        @Override
                        public void onDuration(double duration) {

                        }

                        @Override
                        public void logs(String log) {

                        }
                    });


                }
coder_baba
  • 447
  • 3
  • 21

1 Answers1

0

You can use the following demo to integrate the youtube and play video How to Play YouTube Video in Android App.

vishal jangid
  • 2,967
  • 16
  • 22
  • Yes I know but I am defining activity which is already extending another activity. so how can I use it ? – coder_baba Dec 09 '16 at 07:08
  • use inheritance concept means extend your another activity(which is parent activity of all) by YouTubeActivity – vishal jangid Dec 09 '16 at 07:12
  • Hi Vishal I think you can solve my problem,. Please I need a little help. Avctually I am setting video ID in my recycler view which is extendin RecycleAdapter. and Parent activity is extemnding AppCompactActivity so I am confused – coder_baba Dec 09 '16 at 07:17
  • Extend your parent activity by YouTubeBaseActivity instead of AppCompactActivity – vishal jangid Dec 09 '16 at 08:28