Exemplo n.º 1
0
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
            }
            IsRunning = !IsRunning;

            var message = "";

            try
            {
                mediaRecorder.Stop();
                mediaRecorder.Reset();
                virtualDisplay.Release();
                if (PromptDiscard)
                {
                    var promptDialog = new PromptDialog(DiscardTitle, DiscardMessage);
                    promptDialog.Show(mainActivity.FragmentManager, "PromptDialog");
                    promptDialog.DiscardClick += (sender, e) =>
                    {
                        //删除文件
                        File.Delete(path);
                    };
                    promptDialog.PreviewClick += (sender, e) =>
                    {
                        showPreviewDialog();
                    };
                }
                else
                {
                    showPreviewDialog();
                }
                message = "Completed";
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            finally
            {
                RecordCompleted?.Invoke(this, new ErrorEventArgs(message));
            }
        }
Exemplo n.º 2
0
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
            }

            IsRunning = false;

            RPScreenRecorder.SharedRecorder.StopRecording((RPPreviewViewController controller, Foundation.NSError error) =>
            {
                RecordCompleted?.Invoke(this, new ErrorEventArgs(error?.Description));

                controller.PreviewControllerDelegate = new MyRPPreviewViewControllerDelegate();

                if (PromptDiscard)
                {
                    var alertController = UIAlertController.Create(DiscardTitle, DiscardMessage, UIAlertControllerStyle.Alert);

                    alertController.AddAction(UIAlertAction.Create("丢弃", UIAlertActionStyle.Cancel, (UIAlertAction obj) =>
                    {
                        RPScreenRecorder.SharedRecorder.DiscardRecording(() =>
                        {
                            Debug.WriteLine("!!丢弃录制内容!!");
                        });
                    }));
                    alertController.AddAction(UIAlertAction.Create("预览", UIAlertActionStyle.Default, (UIAlertAction obj) =>
                    {
                        GetVisibleViewController().PresentViewController(controller, true, null);
                    }));

                    GetVisibleViewController().PresentViewController(alertController, true, null);
                }
                else
                {
                    GetVisibleViewController().PresentViewController(controller, true, null);
                }
            });
        }