Beispiel #1
0
        private void SeekToCurrentPos()
        {
            int FNum = 1;
            Redraw = true;
            //Frame rate is actually 30.3, but listed as 30 in the avi. To seek to the proper time, need to adjust for that factor.
            //Switch to float to do decimal math, switch back to integer for actual ms.
            long TimeSeek = (long)((float)ACQ.Position * 1000F * (1F+VideoOffset[ACQ.SelectedChan]));
            bool AVILoaded = false;
            bool pass = false;
            Subtractor = 0;
            while (!AVILoaded)
            {

                CurrentAVI = "";
                string Fname = Path + "\\" + BaseName + string.Format("_{0:d2}", ACQ.SelectedChan) + string.Format("_{0:d4}.avi", FNum);
                while (!File.Exists(Fname) && !pass)
                {
                    FNum++;
                    Fname = Path + "\\" + BaseName + string.Format("_{0:d2}", ACQ.SelectedChan) + string.Format("_{0:d4}.avi", FNum);
                    if (FNum == 30)
                        pass = true;
                }
                if (pass)
                {
                    break;
                }
                media = new VlcMedia(instance, Fname);

                if (player == null)
                {
                    player = new VlcMediaPlayer(media);
                    player.Drawable = VideoPanel.Handle;
                }
                else
                    player.Media = media;
                player.Play();
                while (player.GetLengthMs() == 0)
                { }
                if (player.GetLengthMs() < TimeSeek)
                {
                    TimeSeek = TimeSeek - player.GetLengthMs();
                    Subtractor += player.GetLengthMs();
                    Console.WriteLine(Subtractor);
                    player.Stop();
                    FNum++;
                    media.Dispose();
                }
                else
                {
                    AVILoaded = true;
                    CurrentAVI = Fname;
                    player.seek(TimeSeek);
                }
            }
        }
Beispiel #2
0
        private VlcMediaPlayer LoadFile(VlcMediaPlayer player, string FileName)
        {
            using (VlcMedia media = new VlcMedia(instance, FileName))
            {
                if (player == null)
                    player = new VlcMediaPlayer(media);
                else
                    player.Media = media;
            }

            return player;
        }