예제 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <YVideoView> args)
        {
            base.OnElementChanged(args);
            try
            {
                if (args.OldElement != null)
                {
                    args.OldElement.OnPlayVideo -= PlayVideo;
                }

                if (args.NewElement != null)
                {
                    if (Control == null)
                    {
                        element = args.NewElement;
                        var vi         = LayoutInflater.From(Context);
                        var controller = vi.Inflate(Resource.Layout.y_manager_controls, null);
                        youTubePlayerFragment = MainActivity.Current.SupportFragmentManager.FindFragmentById(Resource.Id.y_fragment) as YouTubePlayerSupportFragment;
                        youTubePlayerFragment.Initialize(Methods.AppSettings.YDeveloperKey, this);
                        youTubePlayerFragment.RetainInstance = true;
                        var relativeLayout = new ARelativeLayout(Context);
                        seeker              = controller.FindViewById <SeekBar>(Resource.Id.seek_bar);
                        video_current_time  = controller.FindViewById <TextView>(Resource.Id.video_current_time);
                        btnPlay             = controller.FindViewById <ImageView>(Resource.Id.y_button);
                        video_duration      = controller.FindViewById <TextView>(Resource.Id.video_duration);
                        video_title         = controller.FindViewById <TextView>(Resource.Id.video_title);
                        fullscreen_button   = controller.FindViewById <ImageView>(Resource.Id.fullscreen_button);
                        youtube_button_prev = controller.FindViewById <ImageView>(Resource.Id.y_button_prev);
                        youtube_button_next = controller.FindViewById <ImageView>(Resource.Id.y_button_next);
                        btnPlay.Click      += TogglePlay;
                        //controller.Click += TogglePlay;
                        youtube_button_prev.Click += (sender, e) => { element?.OnPrev(); };
                        youtube_button_next.Click += (sender, e) => { element?.OnNext(); };
                        element.GetCurrentMedia   += () => Current;
                        element.Stop = () => YPlayer?.Pause();
                        element.Play = () => YPlayer?.Play();
                        relativeLayout.AddView(controller);
                        SetNativeControl(relativeLayout);
                        element.OnPlayVideo   = PlayVideo;
                        element.Abort         = () => aborted = true;
                        element.Reset         = () => aborted = false;
                        element.SetFullScrean = n =>
                        {
                            fullScrean = !n;
                            Fullscreen_button_Click(null, null);
                        };
                        fullscreen_button.Click += Fullscreen_button_Click;
                    }
                }
            }
            catch (Exception e)
            {
                Methods.AppSettings.Logger?.Error(e);
            }
        }
예제 #2
0
        private void InitComponent()
        {
            try
            {
                Fullname            = Mainview.FindViewById <TextView>(Resource.Id.username);
                UserAvatar          = Mainview.FindViewById <ImageView>(Resource.Id.userAvatar);
                MoreIcon            = Mainview.FindViewById <TextView>(Resource.Id.moreicon);
                LikeIcon            = Mainview.FindViewById <TextView>(Resource.Id.Like);
                CommentIcon         = Mainview.FindViewById <TextView>(Resource.Id.Comment);
                Favicon             = Mainview.FindViewById <TextView>(Resource.Id.fav);
                Description         = Mainview.FindViewById <AutoLinkTextView>(Resource.Id.description);
                TimeTextView        = Mainview.FindViewById <TextView>(Resource.Id.time_text);
                ViewCommentsButton  = Mainview.FindViewById <TextView>(Resource.Id.ViewMoreComment);
                LikeCount           = Mainview.FindViewById <TextView>(Resource.Id.Likecount);
                CommentCount        = Mainview.FindViewById <TextView>(Resource.Id.Commentcount);
                CommentRecyclerView = Mainview.FindViewById <RecyclerView>(Resource.Id.RecylerComment);
                ShareIcon           = Mainview.FindViewById <TextView>(Resource.Id.share);
                TypePost            = Mainview.FindViewById <TextView>(Resource.Id.Typepost);

                TextView ViewboxText = Mainview.FindViewById <TextView>(Resource.Id.searchviewbox);
                ViewboxText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                YouTubeFragment = new YouTubePlayerSupportFragment();
                ChildFragmentManager.BeginTransaction().Add(Resource.Id.root, YouTubeFragment, YouTubeFragment.Id.ToString() + DateTime.Now).Commit();
                YouTubeFragment.Initialize(AppSettings.YoutubeKey, this);


                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, MoreIcon, IonIconsFonts.More);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, CommentIcon, IonIconsFonts.IosChatbubbleOutline);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.IosStarOutline);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, LikeIcon, IonIconsFonts.IosHeartOutline);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, TypePost, IonIconsFonts.SocialYoutube);
                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ShareIcon, IonIconsFonts.IosUndoOutline);

                ReadMoreOption = new ReadMoreOption.Builder(MainContext)
                                 .TextLength(200, ReadMoreOption.TypeCharacter)
                                 .MoreLabel(MainContext.GetText(Resource.String.Lbl_ReadMore))
                                 .LessLabel(MainContext.GetText(Resource.String.Lbl_ReadLess))
                                 .MoreLabelColor(Color.ParseColor(AppSettings.MainColor))
                                 .LessLabelColor(Color.ParseColor(AppSettings.MainColor))
                                 .LabelUnderLine(true)
                                 .Build();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void LoadDataVideo()
        {
            try
            {
                if (Video == null)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(Video.Iframe))
                {
                    TabVideosAbout.LoadVideo_Data(Video);

                    if (Video.Iframe.Contains("Youtube") || Video.Iframe.Contains("youtu"))
                    {
                        var ft = SupportFragmentManager.BeginTransaction();

                        VideoIdYoutube = Video.Iframe.Split(new[] { "v=", "/" }, StringSplitOptions.None).LastOrDefault();

                        if (YouTubeFragment == null)
                        {
                            YouTubeFragment = new YouTubePlayerSupportFragment();
                            YouTubeFragment.Initialize(AppSettings.YoutubeKey, this);
                            ft.Add(Resource.Id.root, YouTubeFragment, YouTubeFragment.Id.ToString() + DateTime.Now).Commit();

                            VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Gone;
                            VideoActionsController.ReleaseVideo();
                        }
                        else
                        {
                            VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Gone;
                            VideoActionsController.ReleaseVideo();

                            if (YouTubeFragment.IsAdded)
                            {
                                ft.Show(YouTubeFragment).Commit();
                            }
                            else
                            {
                                YouTubeFragment = new YouTubePlayerSupportFragment();
                                ft.Add(Resource.Id.root, YouTubeFragment, YouTubeFragment.Id.ToString() + DateTime.Now).Commit();
                            }
                            YouTubeFragment.View.Visibility = ViewStates.Visible;
                            YoutubePlayer?.LoadVideo(VideoIdYoutube);
                        }
                    }
                }
                else
                {
                    var dbDatabase = new SqLiteDatabase();
                    var dataVideos = dbDatabase.Get_WatchOfflineVideos_ById(Video.Id);
                    if (dataVideos != null)
                    {
                        VideoActionsController.PlayVideo(dataVideos.Source, dataVideos);
                    }
                    else
                    {
                        VideoActionsController.PlayVideo(Video.Source, Video);
                    }
                    dbDatabase.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void InitComponent()
        {
            try
            {
                MainView = FindViewById <CoordinatorLayout>(Resource.Id.main_content);

                SecondReactionButton = FindViewById <TextView>(Resource.Id.SecondReactionText);
                MainSectionButton    = FindViewById <LinearLayout>(Resource.Id.linerSecondReaction);

                LikeButton = FindViewById <ReactButton>(Resource.Id.ReactButton);

                CommentCount = FindViewById <TextView>(Resource.Id.Commentcount);
                LikeCount    = FindViewById <TextView>(Resource.Id.Likecount);

                TimeText        = FindViewById <AppCompatTextView>(Resource.Id.time_text);
                PrivacyPostIcon = FindViewById <AppCompatTextView>(Resource.Id.privacyPost);
                MoreIcon        = FindViewById <ImageView>(Resource.Id.moreicon);

                Username    = FindViewById <TextViewWithImages>(Resource.Id.username);
                UserAvatar  = FindViewById <CircleImageView>(Resource.Id.userAvatar);
                Description = FindViewById <SuperTextView>(Resource.Id.description);

                PostExtrasLayout = FindViewById <RelativeLayout>(Resource.Id.postExtras);

                ShareLinearLayout          = FindViewById <LinearLayout>(Resource.Id.ShareLinearLayout);
                CommentLinearLayout        = FindViewById <LinearLayout>(Resource.Id.CommentLinearLayout);
                SecondReactionLinearLayout = FindViewById <LinearLayout>(Resource.Id.SecondReactionLinearLayout);

                if (SecondReactionButton != null)
                {
                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine || AppSettings.PostButton == PostButtonSystem.Like)
                    {
                        MainSectionButton.WeightSum           = 3;
                        SecondReactionLinearLayout.Visibility = ViewStates.Gone;
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.Wonder)
                    {
                        MainSectionButton.WeightSum           = 4;
                        SecondReactionLinearLayout.Visibility = ViewStates.Visible;

                        SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.icon_post_wonder_vector, 0, 0, 0);
                        SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Wonder);
                    }
                    else if (AppSettings.PostButton == PostButtonSystem.DisLike)
                    {
                        MainSectionButton.WeightSum           = 4;
                        SecondReactionLinearLayout.Visibility = ViewStates.Visible;
                        SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_action_dislike, 0, 0, 0);
                        SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Dislike);
                    }
                }

                //LikeButton.SetTextColor(Color.White);
                //if (LikeButton?.GetCurrentReaction()?.GetReactType() == ReactConstants.Default)
                //{
                //    LikeButton.CompoundDrawableTintList = ColorStateList.ValueOf(Color.White);
                //}

                YouTubeFragment = new YouTubePlayerSupportFragment();
                SupportFragmentManager.BeginTransaction().Add(Resource.Id.root, YouTubeFragment, YouTubeFragment.Id.ToString() + DateTime.Now).Commit();
                YouTubeFragment.Initialize(AppSettings.YoutubeKey, this);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }