Start() public méthode

public Start ( ) : void
Résultat void
Exemple #1
0
                public void OnPrepared(MediaPlayer mp)
                {
                    // now that the video is ready we can hide the progress bar
                    ProgressBar.Visibility = ViewStates.Gone;

                    MediaController.SetAnchorView(VideoPlayer);

                    // setup a seek listener
                    mp.SetOnSeekCompleteListener(this);

                    // log the series they tapped on.
                    MessageAnalytic.Instance.Trigger(MessageAnalytic.Watch, Name);

                    // if this is a new video, store the URL
                    if (MobileApp.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl != MediaUrl)
                    {
                        MobileApp.Shared.Network.RockMobileUser.Instance.LastStreamingMediaUrl = MediaUrl;
                        VideoPlayer.Start( );

                        // once the video starts, if we're in landscape wide, go full screen
                        if (MainActivity.IsLandscapeWide( ))
                        {
                            ParentTask.NavbarFragment.ToggleFullscreen(true);
                        }
                    }
                    else
                    {
                        // otherwise, resume where we left off
                        mp.SeekTo((int)MobileApp.Shared.Network.RockMobileUser.Instance.LastStreamingMediaPos);
                    }
                }
Exemple #2
0
                public void OnSeekComplete(MediaPlayer mp)
                {
                    VideoPlayer.Start( );

                    // once the video starts, if we're in landscape wide, go full screen
                    if (MainActivity.IsLandscapeWide( ))
                    {
                        ParentTask.NavbarFragment.ToggleFullscreen(true);
                    }
                }
Exemple #3
0
        /// <summary>
        /// 点击开始按钮时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonStart_Click(object sender, EventArgs e)
        {
            #region 识别老照片
            DirectoryInfo TheFolder = new DirectoryInfo(@"C:\Users\mrls\Desktop\video");
            if (!TheFolder.Exists)
            {
                MessageBox.Show("文件夹不存在");
                return;
            }
            var files = TheFolder.GetFiles().Where(x => ".jpg,.png,".Contains(x.Extension.ToLower() + "")).ToList();

            foreach (FileInfo NextFile in files)
            {
                float[] oldEigenValues;
                Bitmap  oldImg   = (Bitmap)Image.FromFile(NextFile.FullName);
                var     oldFaces = ViewFace.FaceDetector(oldImg);
                if (oldFaces.Length > 0)
                {
                    var oldPoints = ViewFace.FaceMark(oldImg, oldFaces[0]);
                    oldEigenValues = ViewFace.Extract(oldImg, oldPoints);
                }
                else
                {
                    oldEigenValues = new float[0];
                }
                var person = new PersonInfo();
                person.Name           = NextFile.Name.Substring(0, NextFile.Name.IndexOf("."));
                person.oldEigenValues = oldEigenValues;
                personInfos.Add(person);
            }

            #endregion
            if (VideoPlayer.IsRunning)
            {
                VideoPlayer.SignalToStop();
                VideoPlayer.WaitForStop();
                TimerDetector.Start();
                ButtonStart.Text = "打开摄像头并识别人脸";
            }
            else
            {
                if (comboBox1.SelectedIndex == -1)
                {
                    return;
                }
                FilterInfo         info         = VideoDevices[comboBox1.SelectedIndex];
                VideoCaptureDevice videoCapture = new VideoCaptureDevice(info.MonikerString);
                VideoPlayer.VideoSource = videoCapture;
                VideoPlayer.Start();
                TimerDetector.Start();
                ButtonStart.Text = "关闭摄像头";
            }
        }
Exemple #4
0
        private void OpenVideoSource(IVideoSource source)
        {
            Cursor = Cursors.WaitCursor;

            CloseVideoSource();

            FPSTimer.Start();

            VideoPlayer.VideoSource = new AsyncVideoSource(source);
            VideoPlayer.Start();

            Cursor = Cursors.Default;
        }
Exemple #5
0
        private void pbCamera_Click(object sender, EventArgs e)
        {
            VideoPlayer.Stop();
            if (ValidateField())
            {
                IsCameraMode      = true;
                pbPreview.Visible = false;

                VideoPlayer.Visible = true;

                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                videoSource  = new VideoCaptureDevice(videoDevices[InitSettings.GetCameraDeviceIndex].MonikerString);
                videoSource.VideoResolution = videoSource.VideoCapabilities[InitSettings.GetCameraDeviceIndex];
                VideoPlayer.VideoSource     = videoSource;
                VideoPlayer.Start();
            }
        }
Exemple #6
0
    public void TogglePlayback()
    {
        if (VideoPlayer.IsPlaying)
        {
            VideoPlayer.IsPaused = !VideoPlayer.IsPaused;
        }
        else if (!VideoRecorder.IsRecording && !VideoRecorder.IsBuffering)
        {
            VideoPlayer.Start(sampleBehaviour.playbackSettings);

            System.TimeSpan clipTime = VideoPlayer.ClipTime;
            clipTimeText.text = string.Format("{0:D2}:{1:D2}", clipTime.Minutes, clipTime.Seconds);

            if (VideoPlayer.IsPlaying)
            {
                buttonImage.sprite = VideoPlayer.IsPaused ? playSprite : pauseSprite;
            }
        }

        seekSlider.Interactable = VideoPlayer.IsPlaying;
    }
Exemple #7
0
 /// <summary>
 /// 点击开始按钮时
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonStart_Click(object sender, EventArgs e)
 {
     if (VideoPlayer.IsRunning)
     {
         Token?.Cancel();
         ButtonStart.Text = "打开摄像头并识别人脸";
     }
     else
     {
         if (comboBox1.SelectedIndex == -1)
         {
             return;
         }
         FilterInfo         info         = VideoDevices[comboBox1.SelectedIndex];
         VideoCaptureDevice videoCapture = new VideoCaptureDevice(info.MonikerString);
         VideoPlayer.VideoSource = videoCapture;
         VideoPlayer.Start();
         ButtonStart.Text = "关闭摄像头";
         Token            = new CancellationTokenSource();
         StartDetector(Token.Token);
     }
 }
Exemple #8
0
 /// <summary>
 /// 点击开始按钮时
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonStart_Click(object sender, EventArgs e)
 {
     if (VideoPlayer.IsRunning)
     {
         VideoPlayer.SignalToStop();
         VideoPlayer.WaitForStop();
         TimerDetector.Start();
         ButtonStart.Text = "打开摄像头并识别人脸";
     }
     else
     {
         if (comboBox1.SelectedIndex == -1)
         {
             return;
         }
         FilterInfo         info         = VideoDevices[comboBox1.SelectedIndex];
         VideoCaptureDevice videoCapture = new VideoCaptureDevice(info.MonikerString);
         VideoPlayer.VideoSource = videoCapture;
         VideoPlayer.Start();
         TimerDetector.Start();
         ButtonStart.Text = "关闭摄像头";
     }
 }
        static void Main(string[] args)
        {
            if (args.Length == 0 || !File.Exists(args[0]))
            {
                Console.WriteLine("Please specify a video file.");
                return;
            }

            var videoPath = args[0];
            var fileName  = Path.GetFileNameWithoutExtension(videoPath);

            using (var videoPlayer = new VideoPlayer())
            {
                videoPlayer.Init(videoPath);
                var captureInterval = TimeSpan.FromSeconds(videoPlayer.Duration.TotalSeconds / (imageCount + 2d));
                var captureIndex    = 0;
                var doneEvent       = new ManualResetEvent(false);

                using (var bitmap = new Bitmap(videoPlayer.VideoWidth, videoPlayer.VideoHeight))
                {
                    videoPlayer.ImageCaptured += (time, data) =>
                    {
                        if (doneEvent.WaitOne(0))
                        {
                            return;
                        }

                        videoPlayer.Pause();
                        var bitmapData = bitmap.LockBits(new Rectangle(0, 0, videoPlayer.VideoWidth, videoPlayer.VideoHeight), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);

                        //Marshal.Copy(data, 0, bitmapData.Scan0, videoPlayer.VideoWidth * videoPlayer.VideoHeight * 4);
                        unsafe
                        {
                            fixed(byte *sData = &data[0])
                            {
                                var pBitmap = (int *)bitmapData.Scan0.ToPointer();
                                var pData   = (int *)sData + videoPlayer.VideoWidth * (videoPlayer.VideoHeight - 1);

                                for (int y = 0; y < videoPlayer.VideoHeight; y++)
                                {
                                    for (int x = 0; x < videoPlayer.VideoWidth; x++)
                                    {
                                        *pBitmap++ = *pData++;
                                    }
                                    pData -= videoPlayer.VideoWidth * 2;
                                }
                            }
                        }

                        bitmap.UnlockBits(bitmapData);
                        bitmap.Save($"{fileName}-{captureIndex++:D2}.png");

                        if (captureIndex < imageCount)
                        {
                            videoPlayer.Position += captureInterval;
                            videoPlayer.Start();
                        }
                        else
                        {
                            doneEvent.Set();
                        }
                    };

                    videoPlayer.Position = captureInterval;
                    videoPlayer.Start();
                    doneEvent.WaitOne();
                    videoPlayer.Stop();
                }
            }
        }