private void OnVlcControlNeedsLibDirectory(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
 {
     var currentAssembly = Assembly.GetEntryAssembly();
     var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
     if (currentDirectory == null)
         return;
     if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
         e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"..\..\lib\x86\"));
     else
         e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"..\..\lib\x64\"));
 }
 private void MediaPlayer_Playing(object sender, Vlc.DotNet.Core.VlcMediaPlayerPlayingEventArgs e)
 {
 }
Exemple #3
0
        public void RebuildPlayer()
        {
            ThrowIfNotInitialize();

            Stop();

            var newPlayer = Vlc.CreateMediaPlayer();

            newPlayer.AudioOutputChannel = VlcMediaPlayer.AudioOutputChannel;
            newPlayer.Brightness         = VlcMediaPlayer.Brightness;
            newPlayer.Chapter            = VlcMediaPlayer.Chapter;
            newPlayer.Contrast           = VlcMediaPlayer.Contrast;
            newPlayer.Gamma = VlcMediaPlayer.Gamma;
            newPlayer.Hue   = VlcMediaPlayer.Hue;
            //newPlayer.IsAdjustEnable = VlcMediaPlayer.IsAdjustEnable;
            newPlayer.IsMute        = VlcMediaPlayer.IsMute;
            newPlayer.Rate          = VlcMediaPlayer.Rate;
            newPlayer.Saturation    = VlcMediaPlayer.Saturation;
            newPlayer.Scale         = VlcMediaPlayer.Scale;
            newPlayer.Subtitle      = VlcMediaPlayer.Subtitle;
            newPlayer.SubtitleDelay = VlcMediaPlayer.SubtitleDelay;
            newPlayer.Volume        = VlcMediaPlayer.Volume;

            if (AudioEqualizer != null)
            {
                newPlayer.SetEqualizer(AudioEqualizer);
            }

            AttachPlayer(newPlayer);
        }
Exemple #4
0
 public static void ReleaseAll()
 {
     if (Vlc != null)
     {
         Vlc.Dispose();
     }
 }
Exemple #5
0
        public async Task <VideoAudioInfo> Execute(Stream thumbnailStream)
        {
            ThumbnailStream = thumbnailStream;
            LibVlcManager.LoadLibVlc(AppDomain.CurrentDomain.BaseDirectory + @"..\..\libvlc");
            Vlc vlc = new Vlc(new[] { "-I", "dummy", "--ignore-config", "--no-video-title" });

            Console.WriteLine($"LibVlcManager: {LibVlcManager.GetVersion()}s");
            mediaPlayer = vlc.CreateMediaPlayer();
            mediaPlayer.SetVideoDecodeCallback(LockCB, unLockCB, DisplayCB, IntPtr.Zero);
            mediaPlayer.SetVideoFormatCallback(VideoFormatCallback, VideoCleanupCallback);
            mediaPlayer.Playing += MediaPlayer_Playing;
            mediaPlayer.Media    = vlc.CreateMediaFromLocation(FilePath);

            await Task.Run(() =>
            {
                mediaPlayer.Play();
                mediaPlayer.IsMute = true;
                Stopwatch s        = new Stopwatch();
                s.Start();
                while (waiting)
                {
                    Thread.Sleep(100);
                }
                s.Stop();
                TimeSpan sec = new TimeSpan(s.ElapsedTicks);
                Console.WriteLine(sec.ToString());
                mediaPlayer.Dispose();
                vlc.Dispose();
            });

            _VideoAudioInfo.Resolution = JsonConvert.SerializeObject(_VideoResolution);
            //_VideoAudioInfo.Thumbnail = ThumbnailStream;
            return(_VideoAudioInfo);
        }
Exemple #6
0
        public void RebuildPlayer()
        {
            if (VlcMediaPlayer == null)
            {
                throw new InvalidOperationException("VlcPlayer is not initialize.");
            }
            Stop();

            var newPlayer = Vlc.CreateMediaPlayer();

            newPlayer.AudioOutputChannel = VlcMediaPlayer.AudioOutputChannel;
            newPlayer.Brightness         = VlcMediaPlayer.Brightness;
            newPlayer.Chapter            = VlcMediaPlayer.Chapter;
            newPlayer.Contrast           = VlcMediaPlayer.Contrast;
            newPlayer.Gamma = VlcMediaPlayer.Gamma;
            newPlayer.Hue   = VlcMediaPlayer.Hue;
            //newPlayer.IsAdjustEnable = VlcMediaPlayer.IsAdjustEnable;
            newPlayer.IsMute        = VlcMediaPlayer.IsMute;
            newPlayer.Rate          = VlcMediaPlayer.Rate;
            newPlayer.Saturation    = VlcMediaPlayer.Saturation;
            newPlayer.Scale         = VlcMediaPlayer.Scale;
            newPlayer.Subtitle      = VlcMediaPlayer.Subtitle;
            newPlayer.SubtitleDelay = VlcMediaPlayer.SubtitleDelay;
            newPlayer.Volume        = VlcMediaPlayer.Volume;

            if (AudioEqualizer != null)
            {
                newPlayer.SetEqualizer(AudioEqualizer);
            }

            AttachPlayer(newPlayer);
        }
Exemple #7
0
 private static void Initialize()
 {
     if (IsInitialized) return;
     Vlc.LoadLibVlc(LibVlcPath);
     Vlc = new Vlc(VlcOption);
     IsInitialized = true;
 }
Exemple #8
0
        private void FileListlst_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string        sfile = FileListlst.Text;
            DirectoryInfo dir   = new DirectoryInfo(_clipsPath);

            FileInfo[] aviFiles = dir.GetFiles("*.avi");

            foreach (FileInfo f in aviFiles)
            {
                string filename = f.Name;
                string fdate    = filename.Substring(5, 10);
                string ftime    = filename.Substring(16, 8);
                string fcamnum  = filename.Substring(3, 1);
                string scamnum  = sfile.Substring(3, 1);
                string rdate    = fdate.Replace("/", "-");
                string rtime    = ftime.Replace(":", ".");

                if (fdate == rdate && ftime == rtime && fcamnum == scamnum)
                {
                    Logger.AppendToLog(DateTime.Now + "   Playback via Search Screen");
                    Vlc      vlc = new Vlc();
                    Playback pb  = new Playback(vlc);
                    pb.Show();
                    pb.CamFilePlayback(filename);
                    Close();
                    return;
                }
            }
        }
        private void MediaPlayer_VlcLibDirectoryNeeded(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
        {
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            if (currentDirectory == null)
                return;
            if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
                e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"vlc\x86\"));
            //e.VlcLibDirectory = new DirectoryInfo(currentDirectory);
            else
                e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"vlc\x64\"));
            //e.VlcLibDirectory = new DirectoryInfo(currentDirectory);

            if (!e.VlcLibDirectory.Exists)
            {
                var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
                folderBrowserDialog.Description = "Select Vlc libraries folder.";
                folderBrowserDialog.RootFolder = Environment.SpecialFolder.Desktop;
                folderBrowserDialog.ShowNewFolderButton = true;
                if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    e.VlcLibDirectory = new DirectoryInfo(folderBrowserDialog.SelectedPath);
                }
            }
        }
Exemple #10
0
 public static void Initialize()
 {
     if (IsInitialized)
     {
         return;
     }
     Vlc.LoadLibVlc(LibVlcPath);
     Vlc = new Vlc(VlcOption);
 }
        public void TestEquals()
        {
            Vlc vlc1 = new Vlc(BitCode, BitLength);
            Vlc vlc2 = new Vlc(0x7, 4);

            Assert.AreEqual(_vlc, vlc1, "Equals()");
            Assert.AreNotEqual(_vlc, vlc2, "Equals()");
            Assert.AreNotEqual(_vlc, null, "Equals()");
        }
        public void TestLength32()
        {
            Vlc vlc = new Vlc(0xFF3FFFFF, 32);

            Assert.AreEqual(0xFF3FFFFFU, vlc.Code, "Code for 32 bits VLC");
            Assert.AreEqual(32, vlc.Length, "Length for 32 bits VLC");
            Assert.AreEqual("11111111001111111111111111111111", vlc.ToString(), "ToString() for 32 bits VLC");
            Assert.AreEqual(0xFF3FFFFFU, (uint)vlc.GetHashCode(), "GetHasCode() for 32 bits VLC");
        }
Exemple #13
0
        public T GetVlc <T>(VlcTable <T> vlcTable)
        {
            Vlc vlc = vlcTable.GetVlc(ShowBits(vlcTable.MaxBits));

            if (vlc == null)
            {
                return(vlcTable.DefaultValue);
            }
            GetBits(vlc.Length);                // Flush the bits
            return(vlcTable[vlc]);
        }
        void MediaPlayer_VlcLibDirectoryNeeded(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
        {
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;

            if (currentDirectory == null)
                return;

            e.VlcLibDirectory = AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture
                                == ProcessorArchitecture.X86 ? new DirectoryInfo(Path.Combine(currentDirectory, @"..\..\..\lib\x86")) : new DirectoryInfo(Path.Combine(currentDirectory, @"..\..\..\lib\x64"));
        }
 /// <summary>
 ///     Release VLC instance.
 /// </summary>
 public static void ReleaseAll()
 {
     if (Vlcs == null)
     {
         return;
     }
     foreach (var vlc in Vlcs)
     {
         vlc.Dispose();
     }
     Vlcs.Clear();
     _defaultVlc = null;
 }
        private void MediaPlayer_VlcLibDirectoryNeeded(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
        {
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            if (currentDirectory == null)
                return;

            //TODO: Remove this as 64bit support for VLC is flakey atm?
            //if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86)
            e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, @"VLCLib\VLC86\"));
            //else
            //    e.VlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, @"lib\x64\"));
        }
Exemple #17
0
        private Size GetMediaSizeWithVlc(string path)
        {
            using (var vlc = new Vlc(VlcSettings.VlcOptions))
            {
                using (var media = vlc.CreateMediaFromPath(path))
                {
                    media.Parse();
                    var tracks = media.GetTracks();
                    var video  = tracks.FirstOrDefault(mt => mt.Type == TrackType.Video) as VideoTrack;

                    return(video == null ? Size.Empty : new Size(video.Width, video.Height));
                }
            }
        }
Exemple #18
0
        private bool HasVideoStream(string path, out Size size)
        {
            using (var vlc = new Vlc(VlcSettings.VlcOptions))
            {
                using (var media = vlc.CreateMediaFromPath(path))
                {
                    media.Parse();
                    var tracks = media.GetTracks();
                    var video  = tracks.FirstOrDefault(mt => mt.Type == TrackType.Video) as VideoTrack;

                    size = video == null ? Size.Empty : new Size(video.Width, video.Height);

                    return(video != null);
                }
            }
        }
Exemple #19
0
        // TODO: Add pipe server for program mutex.
        public FormMain()
        {
            if (!DesignMode)
            {
                Logger.Debug("Initializing LibVLC...");
                Vlc.Initialize();
            }

            Logger.Debug("Initializing windows wallpaper...");
            if (!WindowsWallpaper.Init())
            {
                MessageBox.Show(this, "Failed to initalize windows wallpaper! Failed to acquire desktop window pointer!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            MimeTypesMap.AddOrUpdate("playlist/json", "dpp");
            MimeTypesMap.AddOrUpdate("shadertoy/dpst", "dpst");
            MimeTypesMap.AddOrUpdate("shadertoy/shadertoy", "shadertoy");

            MediaPlayerStore.Instance.RegisterPlayer <VlcMediaPlayer>("video/x-matroska", "video/mp4", "video/mov", "video/avi", "video/wmv", "video/gif", "video/webm");
            MediaPlayerStore.Instance.RegisterPlayer <PictureBoxPlayer>("image/jpeg", "image/png", "image/jpg", "image/bmp", "image/tiff", "image/svg");
            MediaPlayerStore.Instance.RegisterPlayer <ShaderToyPlayer>("shadertoy/dpst", "shadertoy/shadertoy");

            settingsManager.OnSettingsChanged += (sender, settings) => {
                CloseToTray    = settings.CloseToTray;
                MinimizeToTray = settings.MinimizeToTray;
            };
            settingsManager.Load(true);

            if (Settings.StartMinimized)
            {
                WindowState = FormWindowState.Minimized;
            }

            InitializeComponent();
            showToolStripMenuItem.Click += trayShowForm_Click; // Connect the show button in the tray with the required method.
        }
Exemple #20
0
        public void TestGetVlc()
        {
            Assert.AreEqual(new Vlc(0x02, 4), _mockTable.GetVlc(0x040), "GetVlc()");

            // Brute-force test
            int numBits = _mockTable.MaxBits;
            for (uint code = 0U; code < (1U << numBits); code++)
            {
                string bitstring = (new Vlc(code, numBits)).ToString();
                Vlc vlc = _mockTable.GetVlc(code);

                if (vlc != null)
                {
                    Assert.IsTrue(bitstring.StartsWith(vlc.ToString()), "GetVlc(), valid code");
                }
                else
                {
                    for (int i = 0; i < MockVlcData.GetLength(0); i++)
                    {
                        Assert.IsFalse(bitstring.StartsWith(MockVlcData[i, 0] as string), "GetVlc(), invalid code");
                    }
                }
            }
        }
        void myVlcControl_Paused(Vlc.DotNet.Wpf.VlcControl sender, VlcEventArgs<EventArgs> e)
        {

          

        }
Exemple #22
0
 private void OnVlcControlStopped(object sender, Vlc.DotNet.Core.VlcMediaPlayerStoppedEventArgs e)
 {
     playButton.ImageIndex = 0;
 }
Exemple #23
0
 private void OnVlcControlNeedsLibDirectory(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e)
 {
     String programFilesPath = @"D:\Development\VisualStudio\dll\vlc-2.1.5";
     e.VlcLibDirectory = new DirectoryInfo(programFilesPath);
 }
 public void SetUp()
 {
     _vlc = new Vlc(BitCode, BitLength);
 }
 void MediaPlayer_EncounteredError(object sender, Vlc.DotNet.Core.VlcMediaPlayerEncounteredErrorEventArgs e)
 {
     PlayerError(sender, new PlayerErrorEventArgs(e.ToString(), "Error Occurred in VLC Media Player"));
 }
 void MediaPlayer_Playing(object sender, Vlc.DotNet.Core.VlcMediaPlayerPlayingEventArgs e)
 {
     StreamingStatusChanged(ConnectionStatus.Streaming, "");
 }
 private void vlcControl1_PositionChanged(Vlc.DotNet.Forms.VlcControl sender, System.EventArgs args)
 {
     try
     {
         if (selectedChannel == null)
             return;
         //Log("   Looking for audio stream...");
         if (vlcControl1.Media.Statistics.DecodedAudio > 0)
         {
             Log("Observed decoded audio (" + vlcControl1.Media.Statistics.DecodedAudio.ToString() + "). Channel is broadcasting.");
             selectedChannel.BroadcastingChecked = true;
             selectedChannel.IsBroadcasting = true;
             this.vlcControl1.PositionChanged -= new Vlc.DotNet.Core.VlcEventHandler<Vlc.DotNet.Forms.VlcControl, float>(this.vlcControl1_PositionChanged);
             channelLoading = false;
             return;
         }
     }
     catch (Exception ex)
     {
         Log("Position changed failure: " + ex.Message);
     }
     finally
     {
         if (positionChangedCount > 5)
         {
             Log("Timed out looking for audio stream. Channel is NOT broadcasting.");
             this.vlcControl1.PositionChanged -= new Vlc.DotNet.Core.VlcEventHandler<Vlc.DotNet.Forms.VlcControl, float>(this.vlcControl1_PositionChanged);
             channelLoading = false;
             selectedChannel.BroadcastingChecked = true;
         }
         positionChangedCount++;
     }
 }
Exemple #28
0
 public static void ReleaseAll()
 {
     Vlc?.Dispose();
 }
 private void media_ParsedChanged(MediaBase sender, Vlc.DotNet.Core.VlcEventArgs<int> e)
 {
     //throw new NotImplementedException();
 }
        private void VlcControlOnTimeChanged(Vlc.DotNet.Wpf.VlcControl sender, VlcEventArgs<TimeSpan> e)
        {
            if (myVlcControl.Media == null)
            {
                return;
            }
            durationMedia = e.Data;
            alta_txt_curTime.Text = string.Format(
                   "{0:00}:{1:00}:{2:00}",
                   e.Data.Hours,
                   e.Data.Minutes,
                   e.Data.Seconds);

        }
 private void MediaOnParsedChanged(Vlc.DotNet.Core.Medias.MediaBase sender, VlcEventArgs<int> e)
 {
     alta_txt_curTime.Text = string.Format(
         "{0:00}:{1:00}:{2:00}",
         myVlcControl.Media.Duration.Hours,
         myVlcControl.Media.Duration.Minutes,
         myVlcControl.Media.Duration.Seconds);
 }
        private void OnMediaStateChange(MediaBase sender, Vlc.DotNet.Core.VlcEventArgs<Vlc.DotNet.Core.Interops.Signatures.LibVlc.Media.States> e)
        {
            if (e.Data == Vlc.DotNet.Core.Interops.Signatures.LibVlc.Media.States.Playing)
            {
                if (!initialized)
                {
                    if (media.Duration.TotalMilliseconds > 0)
                    {
                        if (!Autoplay)
                            vlc.Pause();
                        else
                            rect.Visibility = System.Windows.Visibility.Hidden;

                        durationMilliseconds = (float)media.Duration.TotalMilliseconds;
                        initialized = true;
                        OnMediaLoaded();
                    }
                    else if (media.SubItems.Count > 0)
                    {
                        var subItems = media.SubItems;
                        media.StateChanged -= OnMediaStateChange;
                        subItems[0].StateChanged += OnMediaStateChange;
                        media = subItems[0];
                        vlc.Media = subItems[0];
                        vlc.Play();
                    }
                    else
                    {
                        OnMediaFailed();
                    }
                }
            }
        }
Exemple #33
0
        /// <summary>
        ///     Initialize VLC player with path of LibVlc and options.
        /// </summary>
        /// <param name="libVlcPath"></param>
        /// <param name="libVlcOption"></param>
        public void Initialize(string libVlcPath, params string[] libVlcOption)
        {
            if (!ApiManager.IsInitialized)
            {
                ApiManager.Initialize(libVlcPath, libVlcOption);
            }

            if (VlcMediaPlayer != null)
            {
                throw new InvalidOperationException("VlcPlayer is been initialized.");
            }

            switch (CreateMode)
            {
            case PlayerCreateMode.NewVlcInstance:
                Vlc = new Vlc(libVlcOption);
                ApiManager.Vlcs.Add(Vlc);
                break;

            case PlayerCreateMode.Default:
            default:
                Vlc = ApiManager.DefaultVlc;
                break;
            }

            VlcMediaPlayer player = Vlc.CreateMediaPlayer();

            _lockCallback    = VideoLockCallback;
            _unlockCallback  = VideoUnlockCallback;
            _displayCallback = VideoDisplayCallback;
            _formatCallback  = VideoFormatCallback;
            _cleanupCallback = VideoCleanupCallback;
            //_audioSetupCallback = AudioFormatSetupCallback;
            //_audioCleanupCallback = AudioFormatCleanupCallback;
            //_audioPlayCallback = AudioPlayCallback;
            //_audioPauseCallback = AudioPauseCallback;
            //_audioResumeCallback = AudioResumeCallback;
            //_audioFlushCallback = AudioFlushCallback;
            //_audioDrainCallback = AudioDrainCallback;
            //_audioSetVolumeCallback = AudioSetVolumeCallback;

            _lockCallbackHandle    = GCHandle.Alloc(_lockCallback);
            _unlockCallbackHandle  = GCHandle.Alloc(_unlockCallback);
            _displayCallbackHandle = GCHandle.Alloc(_displayCallback);
            _formatCallbackHandle  = GCHandle.Alloc(_formatCallback);
            _cleanupCallbackHandle = GCHandle.Alloc(_cleanupCallback);
            //_audioSetupCallbackHandle = GCHandle.Alloc(_audioSetupCallback);
            //_audioCleanupCallbackHandle = GCHandle.Alloc(_audioCleanupCallback);
            //_audioPlayCallbackHandle = GCHandle.Alloc(_audioPlayCallback);
            //_audioPauseCallbackHandle = GCHandle.Alloc(_audioPauseCallback);
            //_audioResumeCallbackHandle = GCHandle.Alloc(_audioResumeCallback);
            //_audioFlushCallbackHandle = GCHandle.Alloc(_audioFlushCallback);
            //_audioDrainCallbackHandle = GCHandle.Alloc(_audioDrainCallback);
            //_audioSetVolumeCallbackHandle = GCHandle.Alloc(_audioSetVolumeCallback);

            if (player == null)
            {
                throw new Exception("Vlc media player initialize fail.");
            }

            AttachPlayer(player);
        }
        void media_ParsedChanged(MediaBase sender, Vlc.DotNet.Core.VlcEventArgs<int> e)
        {
          

        }
Exemple #35
0
 private void VlcVideoPlayer_PositionChanged(object sender, Vlc.DotNet.Core.VlcMediaPlayerPositionChangedEventArgs e)
 {
     var frameposition = e.NewPosition * (selVideoRange.FrameMax - selVideoRange.FrameMin);
     selVideoRange.CurrentValue = (int)frameposition;
 }
 private void myVlcControl_Stopped(Vlc.DotNet.Wpf.VlcControl sender, Vlc.DotNet.Core.VlcEventArgs<EventArgs> e)
 {
     
 }
 public void TearDown()
 {
     _vlc = null;
 }
 private void myVlcControl_Playing(Vlc.DotNet.Wpf.VlcControl sender, Vlc.DotNet.Core.VlcEventArgs<EventArgs> e)
 {
    
 }
Exemple #39
0
        /// <summary>
        ///     Initialize VLC player with path of LibVlc and options.
        /// </summary>
        /// <param name="libVlcPath"></param>
        /// <param name="libVlcOption"></param>
        public void Initialize(String libVlcPath, params String[] libVlcOption)
        {
            if (!ApiManager.IsInitialized)
            {
                ApiManager.Initialize(libVlcPath, libVlcOption);
            }

            switch (CreateMode)
            {
            case PlayerCreateMode.NewVlcInstance:
                var vlc = new Vlc(libVlcOption);
                VlcMediaPlayer = vlc.CreateMediaPlayer();
                ApiManager.Vlcs.Add(vlc);
                break;

            case PlayerCreateMode.Default:
            default:
                VlcMediaPlayer = ApiManager.DefaultVlc.CreateMediaPlayer();
                break;
            }

            if (VlcMediaPlayer != null)
            {
                VlcMediaPlayer.PositionChanged += VlcMediaPlayerPositionChanged;
                VlcMediaPlayer.TimeChanged     += VlcMediaPlayerTimeChanged;
                VlcMediaPlayer.Playing         += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Paused          += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Stoped          += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Opening         += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.Buffering       += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.EndReached      += VlcMediaPlayerStateChanged;
                VlcMediaPlayer.SeekableChanged += VlcMediaPlayerSeekableChanged;
                VlcMediaPlayer.LengthChanged   += VlcMediaPlayerLengthChanged;

                _lockCallback    = VideoLockCallback;
                _unlockCallback  = VideoUnlockCallback;
                _displayCallback = VideoDisplayCallback;
                _formatCallback  = VideoFormatCallback;
                _cleanupCallback = VideoCleanupCallback;
                //_audioSetupCallback = AudioFormatSetupCallback;
                //_audioCleanupCallback = AudioFormatCleanupCallback;
                //_audioPlayCallback = AudioPlayCallback;
                //_audioPauseCallback = AudioPauseCallback;
                //_audioResumeCallback = AudioResumeCallback;
                //_audioFlushCallback = AudioFlushCallback;
                //_audioDrainCallback = AudioDrainCallback;
                //_audioSetVolumeCallback = AudioSetVolumeCallback;

                _lockCallbackHandle    = GCHandle.Alloc(_lockCallback);
                _unlockCallbackHandle  = GCHandle.Alloc(_unlockCallback);
                _displayCallbackHandle = GCHandle.Alloc(_displayCallback);
                _formatCallbackHandle  = GCHandle.Alloc(_formatCallback);
                _cleanupCallbackHandle = GCHandle.Alloc(_cleanupCallback);
                //_audioSetupCallbackHandle = GCHandle.Alloc(_audioSetupCallback);
                //_audioCleanupCallbackHandle = GCHandle.Alloc(_audioCleanupCallback);
                //_audioPlayCallbackHandle = GCHandle.Alloc(_audioPlayCallback);
                //_audioPauseCallbackHandle = GCHandle.Alloc(_audioPauseCallback);
                //_audioResumeCallbackHandle = GCHandle.Alloc(_audioResumeCallback);
                //_audioFlushCallbackHandle = GCHandle.Alloc(_audioFlushCallback);
                //_audioDrainCallbackHandle = GCHandle.Alloc(_audioDrainCallback);
                //_audioSetVolumeCallbackHandle = GCHandle.Alloc(_audioSetVolumeCallback);

                VlcMediaPlayer.SetVideoDecodeCallback(_lockCallback, _unlockCallback, _displayCallback, IntPtr.Zero);
                VlcMediaPlayer.SetVideoFormatCallback(_formatCallback, _cleanupCallback);
                //VlcMediaPlayer.SetAudioCallback(_audioPlayCallback, _audioPauseCallback, _audioResumeCallback, _audioFlushCallback, _audioDrainCallback);
                //VlcMediaPlayer.SetAudioFormatCallback(_audioSetupCallback, _audioCleanupCallback);
                //VlcMediaPlayer.SetAudioVolumeCallback(_audioSetVolumeCallback);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void VlcControlOnPositionChanged(Vlc.DotNet.Wpf.VlcControl sender, VlcEventArgs<float> e)
        {
            if (myPositionChanging)
            {
                return;
            }

            barTimeSeek.Value = (int)(e.Data * 100);
        }
 private void MediaPlayer_EncounteredError(object sender, Vlc.DotNet.Core.VlcMediaPlayerEncounteredErrorEventArgs e)
 {
     MessageBox.Show(this, e.ToString(), "error");
 }
 void myVlcControl_Playing(Vlc.DotNet.Wpf.VlcControl sender, VlcEventArgs<EventArgs> e)
 {
     topImage.Animation_Opacity_View_Frame(false);
     HideControl();
 }