示例#1
0
        private void CommentsAdapter_AvatarClick(object sender, AvatarCommentAdapterClickEventArgs e)
        {
            try
            {
                if (YoutubePlayer != null && YoutubePlayer.IsPlaying)
                {
                    YoutubePlayer.Pause();
                }

                AppTools.OpenProfile(MainContext, e.Class.UserId.ToString(), e.Class);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
 public void Pause()
 {
     if (player != null)
     {
         player.Pause();
     }
 }
示例#3
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);
            }
        }
示例#4
0
 public void TogglePlay(object sender, EventArgs arg)
 {
     if (YPlayer.IsPlaying)
     {
         YPlayer.Pause();
     }
     else
     {
         YPlayer.Play();
     }
 }
示例#5
0
        protected override void OnStop()
        {
            try
            {
                if (YoutubePlayer != null && YoutubePlayer.IsPlaying)
                {
                    YoutubePlayer.Pause();
                }

                base.OnStop();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
 private void TxtRecordLive_Click(object sender, EventArgs e)
 {
     this.Dismiss();
     VideoRecorderActivitiy.ResponseFragment = ResponseFragment;
     if (userResponse == UserResponse.Video)
     {
         if (ContextCompat.CheckSelfPermission(this.Activity, camPermission) == (int)Permission.Granted &&
             ContextCompat.CheckSelfPermission(this.Activity, micPermission) == (int)Permission.Granted)
         {
             Intent intent = new Intent(this.Context, typeof(VideoRecorderActivitiy));
             intent.PutExtra("UserResponseType", (int)userResponse);
             intent.PutExtra("videoId", videoId);
             StartActivity(intent);
         }
         else
         {
             RecordResponseManager.GetCameraAndMicCompatPermission(this.Activity, new string[] { camPermission, micPermission });
         }
     }
     else if (userResponse == UserResponse.Audio)
     {
         if (ContextCompat.CheckSelfPermission(this.Activity, micPermission) == (int)Permission.Granted)
         {
             Intent intent = new Intent(this.Context, typeof(VideoRecorderActivitiy));
             intent.PutExtra("UserResponseType", (int)userResponse);
             intent.PutExtra("videoId", videoId);
             StartActivity(intent);
         }
         else
         {
             RecordResponseManager.GetCameraAndMicCompatPermission(this.Activity, new string[] { camPermission });
         }
     }
     if (VideoController != null)
     {
         VideoController.SetStopvideo();
         VideoController.ReleaseVideo();
     }
     if (YoutubePlayer != null && YoutubePlayer.IsPlaying)
     {
         YoutubePlayer?.Pause();
     }
 }