Example #1
0
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Set libvlc.dll and libvlccore.dll directory path
            VlcContext.LibVlcDllsPath = @"C:\Projets\vlc-1.1.11"; // CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;

            // Set the vlc plugins directory path
            VlcContext.LibVlcPluginsPath = @"C:\Projets\vlc-1.1.11\pugins"; //CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;

            // Ignore the VLC configuration file
            VlcContext.StartupOptions.IgnoreConfig = true;

            // Enable file based logging
            VlcContext.StartupOptions.LogOptions.LogInFile = true;

            // Shows the VLC log console (in addition to the applications window)
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;

            // Set the log level for the VLC instance
            VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;

            // Initialize the VlcContext
            VlcContext.Initialize();

            Application.Run(new VlcPlayer());

            // Close the VlcContext
            VlcContext.CloseAll();
        }
Example #2
0
 public static void Shutdown()
 {
     if (IsInitialized)
     {
         VlcContext.CloseAll();
     }
 }
        private void InitVlcContext()
        {
            VlcContext.CloseAll();

            //Set libvlc.dll and libvlccore.dll directory path
            VlcContext.LibVlcDllsPath = LibVlcDllsPath;
            //Set the vlc plugins directory path
            VlcContext.LibVlcPluginsPath = LibVlcPluginsPath;

            //Set the startup options (http://wiki.videolan.org/VLC_command-line_help)
            if (Options != null)
            {
                var optionList = Options.Split(' ');
                foreach (var option in optionList)
                {
                    VlcContext.StartupOptions.AddOption(option);
                }
            }

            //Set debug options
            VlcContext.StartupOptions.IgnoreConfig                 = true;
            VlcContext.StartupOptions.LogOptions.LogInFile         = DebugMode;
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = DebugMode;
            VlcContext.StartupOptions.LogOptions.Verbosity         = DebugMode ? VlcLogVerbosities.Debug : VlcLogVerbosities.None;

            VlcContext.Initialize();
        }
Example #4
0
        /// <summary>
        /// 初始化流媒体播放器
        /// </summary>m
        public void VlcMediaPlayerInit(Action <VlcControl, string> vlcCallBack)
        {
            try
            {
                //vlc配置参数
                VlcContext.StartupOptions.IgnoreConfig                 = true;
                VlcContext.StartupOptions.LogOptions.LogInFile         = false;
                VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;
                VlcContext.StartupOptions.LogOptions.Verbosity         = VlcLogVerbosities.None;
                VlcContext.LibVlcPluginsPath = Environment.CurrentDirectory + "\\plugins";
                VlcContext.LibVlcDllsPath    = Environment.CurrentDirectory;
                //流媒体播放器初始化
                VlcContext.Initialize();
                //播放器实例生成
                vlcPlayer = new VlcControl();

                //// 创建绑定,绑定Image
                //Binding bing = new Binding();
                //bing.Source = vlcPlayer;
                //bing.Path = new PropertyPath("VideoSource");
                //img.SetBinding(Image.SourceProperty, bing);
                vlcCallBack(vlcPlayer, "VideoSource");
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(this.GetType(), ex);
            }
            finally
            {
            }
        }
Example #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Set libvlc.dll and libvlccore.dll directory path
            //VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_X86;
            //Set the vlc plugins directory path
            //VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_X86;
            VlcContext.LibVlcDllsPath    = @"VLCPortable\App\vlc\";
            VlcContext.LibVlcPluginsPath = @"VLCPortable\App\vlc\plugins\";

            //Set the startup options
            VlcContext.StartupOptions.IgnoreConfig                 = true;
            VlcContext.StartupOptions.LogOptions.LogInFile         = true;
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
            VlcContext.StartupOptions.LogOptions.Verbosity         = VlcLogVerbosities.Debug;


            //Initialize the VlcContext
            VlcContext.Initialize();
            Application.Run(new Form1());


            //Close the VlcContext
            VlcContext.CloseAll();
        }
Example #6
0
        /// <summary>
        /// Ensures the media player created.
        /// </summary>
        private void EnsureMediaPlayerCreated()
        {
            if (_initialized)
            {
                return;
            }

            var path = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

            VlcContext.LibVlcDllsPath    = path;
            VlcContext.LibVlcPluginsPath = Path.Combine(path, "plugins");

            // Set the vlc plugins directory path
            //VlcContext.LibVlcDllsPath = @"C:\\Program Files (x86)\\VideoLAN\\VLC";
            //VlcContext.LibVlcPluginsPath = @"C:\\Program Files (x86)\\VideoLAN\\VLC\\plugins";

            /* Setting up the configuration of the VLC instance.
             * You can use any available command-line option using the AddOption function (see last two options).
             * A list of options is available at
             *     http://wiki.videolan.org/VLC_command-line_help
             * for example. */

            // Ignore the VLC configuration file
            VlcContext.StartupOptions.IgnoreConfig = true;

            // Enable file based logging
            VlcContext.StartupOptions.LogOptions.LogInFile = false;

            // Shows the VLC log console (in addition to the applications window)
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;

            // Set the log level for the VLC instance
            VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;

            var configStrings = new List <string>
            {
                "-I",
                "dummy",
                "--ignore-config",
                "--no-osd",
                "--disable-screensaver",
                "--no-video-title-show"
            };

            if (_config.Configuration.VlcConfiguration.EnableGpuAcceleration)
            {
                configStrings.Add("--ffmpeg-hw");
            }

            foreach (var opt in configStrings)
            {
                VlcContext.StartupOptions.AddOption(opt);
            }

            // Initialize the VlcContext
            VlcContext.Initialize();

            _initialized = true;
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool isAMD64 = System.IO.Directory.Exists(CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64);
            bool isX86   = System.IO.Directory.Exists(CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_X86);

            if (isAMD64 || isX86)
            {
                try
                {
                    if (isAMD64)
                    {
                        //Set libvlc.dll and libvlccore.dll directory path
                        VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
                        //Set the vlc plugins directory path
                        VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;
                    }
                    else
                    {
                        //Set libvlc.dll and libvlccore.dll directory path
                        VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_X86;
                        //Set the vlc plugins directory path
                        VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_X86;
                    }

                    //Set the startup options
                    VlcContext.StartupOptions.IgnoreConfig                 = true;
                    VlcContext.StartupOptions.LogOptions.LogInFile         = true;
                    VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
                    VlcContext.StartupOptions.LogOptions.Verbosity         = VlcLogVerbosities.None;

                    //Initialize the VlcContext
                    VlcContext.Initialize();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed loading the optional VLC library. Channel previewing may not work correctly. Do you have the latest version of VLC installed? " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("VLC DLL files not found in either of the standard locations: " + CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64 + " or " + CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_X86);
            }

            Application.Run(new Main());

            if (isAMD64 || isX86)
            {
                try
                {
                    //Close the VlcContexttry
                    VlcContext.CloseAll();
                }
                catch (Exception) { }
            }
        }
Example #8
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool dispose)
        {
            if (dispose)
            {
                DisposePlayer();

                VlcContext.CloseAll();
            }
        }
Example #9
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            InitVLC();

            Application.Run(new MainForm());

            VlcContext.CloseAll();
        }
Example #10
0
        public MainViewModel()
        {
            /* Setting up the configuration of the VLC instance.
             * You can use any available command-line option using the AddOption function (see last two options).
             * A list of options is available at
             *     http://wiki.videolan.org/VLC_command-line_help
             * for example. */
            // Ignore the VLC configuration file
            VlcContext.StartupOptions.IgnoreConfig = true;
            // Disable file based logging
            VlcContext.StartupOptions.LogOptions.LogInFile = false;
            // Disable the VLC log console (in addition to the applications window)
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
            // Set the log level for the VLC instance
            VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;
            // Disable showing the movie file name as an overlay
            VlcContext.StartupOptions.AddOption("--no-video-title-show");
            // Pauses the playback of a movie on the last frame
            VlcContext.StartupOptions.AddOption("--play-and-pause");

            var ofd = new OpenFileDialog();

            ofd.Filter           = "Libvlc Library (libvlc.dll)|*.dll|All Files|*.*";
            ofd.InitialDirectory = VlcContext.LibVlcDllsPath;
            ofd.Multiselect      = false;
            while (true)
            {
                var result = ofd.ShowDialog();
                if (result.HasValue && result.Value)
                {
                    try
                    {
                        // Set libvlc.dll and libvlccore.dll directory path
                        VlcContext.LibVlcDllsPath = ofd.File.Directory.FullName;
                        // Set the vlc plugins directory path
                        VlcContext.LibVlcPluginsPath = System.IO.Path.Combine(VlcContext.LibVlcDllsPath, "plugins");
                        // Initialize the VlcContext
                        VlcContext.Initialize();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Vlc.DotNet.silverlight.Sample", MessageBoxButton.OK);
                    }
                    if (VlcContext.IsInitialized)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
        }
 public override void Unload()
 {
     Reset();
     if (_player != null)
     {
         _player.Stop();
     }
     _player = null;
     _media  = null;
     VlcContext.CloseAll();
 }
Example #12
0
        public void initVLC()
        {
            if (Environment.Is64BitOperatingSystem)
            {
                VlcContext.LibVlcDllsPath = @"VLC\x86";
                // Set the vlc plugins directory path
                VlcContext.LibVlcPluginsPath = @"VLC\x86\plugins";
            }
            else
            {
                // Set libvlc.dll and libvlccore.dll directory path
                VlcContext.LibVlcDllsPath = @"VLC\x86";
                // Set the vlc plugins directory path
                VlcContext.LibVlcPluginsPath = @"VLC\x86\plugins";
            }

            // Ignore the VLC configuration file
            VlcContext.StartupOptions.IgnoreConfig = true;

            // Enable file based logging
            VlcContext.StartupOptions.LogOptions.LogInFile = true;

            // Shows the VLC log console (in addition to the applications window)
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;

            // Set the log level for the VLC instance
            //VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Warnings;
            VlcContext.StartupOptions.AddOption("--ffmpeg-hw");
            // Disable showing the movie file name as an overlay
            VlcContext.StartupOptions.AddOption("--no-video-title-show");
            VlcContext.StartupOptions.AddOption("--rtsp-tcp");
            VlcContext.StartupOptions.AddOption("--rtsp-mcast");
            // VlcContext.StartupOptions.AddOption("--rtsp-host=192.168.10.35");
            // VlcContext.StartupOptions.AddOption("--sap-addr=192.168.10.35");
            VlcContext.StartupOptions.AddOption("--rtsp-port=8554");
            VlcContext.StartupOptions.AddOption("--rtp-client-port=8554");
            VlcContext.StartupOptions.AddOption("--sout-rtp-rtcp-mux");
            VlcContext.StartupOptions.AddOption("--rtsp-wmserver");


            VlcContext.StartupOptions.AddOption("--file-caching=18000");
            VlcContext.StartupOptions.AddOption("--sout-rtp-caching=18000");
            VlcContext.StartupOptions.AddOption("--sout-rtp-port=8554");
            VlcContext.StartupOptions.AddOption("--sout-rtp-proto=tcp");
            VlcContext.StartupOptions.AddOption("--network-caching=1000");

            // Pauses the playback of a movie on the last frame
            VlcContext.StartupOptions.AddOption("--play-and-pause");
            VlcContext.CloseAll();
            // Initialize the VlcContext
            VlcContext.Initialize();
        }
Example #13
0
 private void exitMediaPlayer()
 {
     if (myVlcControl.IsPlaying)
     {
         myVlcControl.Stop();
     }
     if (VlcContext.IsInitialized)
     {
         VlcContext.CloseAll();
     }
     _allowKeyPressMonitoring = false;
     PageNavigation.Instance.NavigateBack(_callingPage);
 }
Example #14
0
        /// <summary>
        /// Constructor of VlcControl
        /// </summary>
        public VlcControl()
        {
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                return;
            }

            VideoBrush = new ImageBrush();

            if (!VlcContext.IsInitialized)
            {
                VlcContext.Initialize();
            }

            VlcContext.HandleManager.MediaPlayerHandles[this] = VlcContext.InteropManager.MediaPlayerInterops.NewInstance.Invoke(VlcContext.HandleManager.LibVlcHandle);
            AudioProperties    = new VlcAudioProperties(this);
            VideoProperties    = new VlcVideoProperties(this);
            LogProperties      = new VlcLogProperties();
            Medias             = new VlcMediaListPlayer(this);
            AudioOutputDevices = new VlcAudioOutputDevices();

            EventsHelper.ExecuteRaiseEventDelegate =
                delegate(Delegate singleInvoke, object sender, object arg)
            {
                if (Dispatcher.CheckAccess())
                {
                    Dispatcher.Invoke(DispatcherPriority.Normal, singleInvoke, sender, arg);
                }
                else
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Normal, singleInvoke, sender, arg);
                }
            };
            InitEvents();

            myVideoLockCallback         = LockCallback;
            myVideoLockCallbackHandle   = GCHandle.Alloc(myVideoLockCallback);
            myVideoUnlockCallback       = UnlockCallback;
            myVideoUnlockCallbackHandle = GCHandle.Alloc(myVideoUnlockCallback);

            myVideoSetFormat       = VideoSetFormat;
            myVideoSetFormatHandle = GCHandle.Alloc(myVideoSetFormat);
            myVideoCleanup         = VideoCleanup;
            myVideoCleanupHandle   = GCHandle.Alloc(myVideoCleanup);

            CompositionTarget.Rendering += CompositionTargetRendering;

            VlcContext.InteropManager.MediaPlayerInterops.VideoInterops.SetFormatCallbacks.Invoke(VlcContext.HandleManager.MediaPlayerHandles[this], myVideoSetFormat, myVideoCleanup);
            VlcContext.InteropManager.MediaPlayerInterops.VideoInterops.SetCallbacks.Invoke(VlcContext.HandleManager.MediaPlayerHandles[this], myVideoLockCallback, myVideoUnlockCallback, null, IntPtr.Zero);
        }
Example #15
0
        /// <summary>
        /// Constructor of VlcControl
        /// </summary>
        public VlcControl()
        {
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                return;
            }

            VideoBrush = new ImageBrush();

            if (!VlcContext.IsInitialized)
            {
                VlcContext.Initialize();
            }

            VlcContext.HandleManager.MediaPlayerHandles[this] = VlcContext.InteropManager.MediaPlayerInterops.NewInstance.Invoke(VlcContext.HandleManager.LibVlcHandle);
            AudioProperties    = new VlcAudioProperties(this);
            VideoProperties    = new VlcVideoProperties(this);
            LogProperties      = new VlcLogProperties();
            AudioOutputDevices = new VlcAudioOutputDevices();

            EventsHelper.ExecuteRaiseEventDelegate =
                delegate(Delegate singleInvoke, object sender, object arg)
            {
                var dispatcherObject = singleInvoke.Target as DispatcherObject;
                if (dispatcherObject == null)
                {
                    singleInvoke.DynamicInvoke(sender, arg);
                    return;
                }
                if (EventsHelper.CanRaiseEvent)
                {
                    dispatcherObject.Dispatcher.Invoke(singleInvoke, new[] { sender, arg });
                }
            };
            InitEvents();

            myVideoLockCallback       = LockCallback;
            myVideoLockCallbackHandle = GCHandle.Alloc(myVideoLockCallback);

            myVideoSetFormat       = VideoSetFormat;
            myVideoSetFormatHandle = GCHandle.Alloc(myVideoSetFormat);
            myVideoCleanup         = VideoCleanup;
            myVideoCleanupHandle   = GCHandle.Alloc(myVideoCleanup);

            CompositionTarget.Rendering += CompositionTargetRendering;

            VlcContext.InteropManager.MediaPlayerInterops.VideoInterops.SetFormatCallbacks.Invoke(VlcContext.HandleManager.MediaPlayerHandles[this], myVideoSetFormat, myVideoCleanup);
            VlcContext.InteropManager.MediaPlayerInterops.VideoInterops.SetCallbacks.Invoke(VlcContext.HandleManager.MediaPlayerHandles[this], myVideoLockCallback, null, null, IntPtr.Zero);
        }
Example #16
0
        /// <summary>
        /// Constructor of VlcControl
        /// </summary>
        public VlcControl()
        {
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                return;
            }
            if (!VlcContext.IsInitialized)
            {
                VlcContext.Initialize();
            }
            VlcContext.HandleManager.MediaPlayerHandles[this] =
                VlcContext.InteropManager.MediaPlayerInterops.NewInstance.Invoke(
                    VlcContext.HandleManager.LibVlcHandle);
            AudioProperties    = new VlcAudioProperties(this);
            VideoProperties    = new VlcVideoProperties(this);
            Medias             = new VlcMediaListPlayer(this);
            LogProperties      = new VlcLogProperties();
            AudioOutputDevices = new VlcAudioOutputDevices();

            EventsHelper.ExecuteRaiseEventDelegate =
                delegate(Delegate singleInvoke, object sender, object arg)
            {
                var syncInvoke = singleInvoke.Target as ISynchronizeInvoke;
                if (syncInvoke == null)
                {
                    singleInvoke.DynamicInvoke(new [] { sender, arg });
                    return;
                }
                try
                {
                    if (syncInvoke.InvokeRequired)
                    {
                        syncInvoke.Invoke(singleInvoke, new [] { sender, arg });
                    }
                    else
                    {
                        singleInvoke.DynamicInvoke(sender, arg);
                    }
                }
                catch (ObjectDisposedException)
                {
                    //Because IsDisposed was true and IsDisposed could be false now...
                }
            };

            InitEvents();
            HandleCreated += OnHandleCreated;
        }
Example #17
0
 private void UIRootView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (this.clock != null)
     {
         this.clock.Controller.Stop();
     }
     this.mainClock.Controller.Stop();
     this.ClockMouse.Controller.Stop();
     if (myVlcControl.IsPlaying)
     {
         myVlcControl.Stop();
     }
     // Config.Write(App.FileName, App.setting);
     this.Tcp_Server = null;
     VlcContext.CloseAll();
 }
Example #18
0
        private static void SetUpVlcContext()
        {
            //Set libvlc.dll and libvlccore.dll directory path
            VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
            //Set the vlc plugins directory path
            VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;

            //Set the startup options
            VlcContext.StartupOptions.IgnoreConfig                 = true;
            VlcContext.StartupOptions.LogOptions.LogInFile         = false;
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;
            VlcContext.StartupOptions.LogOptions.Verbosity         = VlcLogVerbosities.None;

            //Initialize the VlcContext
            VlcContext.Initialize();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VlcPlayer"/> class.
        /// </summary>
        public VideoPlayerControl()
        {
            // Set libvlc.dll and libvlccore.dll directory path
            VlcContext.LibVlcDllsPath = "."; //@"C:\Program Files\VideoLAN\vlc-1.2.0";

            // Set the vlc plugins directory path
            VlcContext.LibVlcPluginsPath = @".\plugins"; //@"C:\Program Files\VideoLAN\vlc-1.2.0\plugins";

            /* Setting up the configuration of the VLC instance.
             * You can use any available command-line option using the AddOption function (see last two options).
             * A list of options is available at
             *     http://wiki.videolan.org/VLC_command-line_help
             * for example. */

            // Ignore the VLC configuration file
            VlcContext.StartupOptions.IgnoreConfig = true;

            // Enable file based logging
            VlcContext.StartupOptions.LogOptions.LogInFile = true;

            // Shows the VLC log console (in addition to the applications window)
#if DEBUG
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
#endif

            // Set the log level for the VLC instance
            VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;

            // Disable showing the movie file name as an overlay
            VlcContext.StartupOptions.AddOption("--no-video-title-show");

            // Pauses the playback of a movie on the last frame
            VlcContext.StartupOptions.AddOption("--play-and-pause");

            VlcContext.StartupOptions.AddOption("--file-caching=2000");
            VlcContext.StartupOptions.AddOption("--ffmpeg-skiploopfilter=4");

            // Initialize the VlcContext
            VlcContext.Initialize();

            InitializeComponent();

            myVlcControl.VideoProperties.Scale = 2.0f;
            myVlcControl.PositionChanged      += VlcControlOnPositionChanged;
            //myVlcControl.TimeChanged += VlcControlOnTimeChanged;
            //Closing += MainWindowOnClosing;
        }
Example #20
0
        // Public Methods (1) 

        public static void InitVLC()
        {
            var appDir = new DirectoryInfo(Environment.CurrentDirectory);
            var vlcDir = new DirectoryInfo(Path.Combine(appDir.FullName,
                                                        "vlc"));

            VlcContext.LibVlcDllsPath    = vlcDir.FullName;
            VlcContext.LibVlcPluginsPath = Path.Combine(vlcDir.FullName,
                                                        "plugins");

            VlcContext.StartupOptions.IgnoreConfig                 = true;
            VlcContext.StartupOptions.LogOptions.LogInFile         = false;
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;
            VlcContext.StartupOptions.LogOptions.Verbosity         = VlcLogVerbosities.Warnings;

            VlcContext.Initialize();
        }
Example #21
0
        public bool IsVlcLibDirectoryValid(string vlcLibDirectory)
        {
            var oldValue = VlcContext.LibVlcDllsPath;
            var result   = true;

            VlcContext.LibVlcDllsPath = vlcLibDirectory;
            try
            {
                VlcContext.Initialize();
            }
            catch (Exception ex)
            {
                myErrors["VlcLibDirectory"] = ex.Message;
                result = false;
            }
            finally
            {
                VlcContext.LibVlcDllsPath = oldValue;
            }
            return(result);
        }
Example #22
0
        public static void Init()
        {
            if (!IsAvailable)
            {
                throw new InvalidOperationException("VLC is not available (not installed).");
            }

            //Set libvlc.dll and libvlccore.dll directory path
            //VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
            //Set the vlc plugins directory path
            //VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;

            // TODO: what happens if VLC is not available?

            //Set the startup options
            VlcContext.StartupOptions.IgnoreConfig = true;
            //VlcContext.StartupOptions.LogOptions.LogInFile = true;
            //VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
            VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;
            VlcContext.StartupOptions.AddOption("--no-osd");
            VlcContext.LibVlcDllsPath    = Path;
            VlcContext.LibVlcPluginsPath = Path + @"\plugins";

            //Initialize the VlcContext
            try
            {
                VlcContext.Initialize();
            }
            catch (FileNotFoundException)
            {
                throw new InvalidOperationException("VLC is not available (libvlc not found). Try installing the 32-bit version of VLC.");
            }
            catch (TargetInvocationException)
            {
                throw new InvalidOperationException("VLC could not be loaded. Try installing the latest version (or any version >= 1.2).");
            }

            IsInitialized = true;
        }
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YoutubeAudioPlayer"/> class.
        /// </summary>
        public YoutubeAudioPlayer()
        {
            if (Environment.Is64BitOperatingSystem)
            {
                VlcContext.LibVlcDllsPath    = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
                VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;
            }

            else
            {
                VlcContext.LibVlcDllsPath    = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_X86;
                VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_X86;
            }

            VlcContext.StartupOptions.IgnoreConfig = true;

            VlcContext.Initialize();

            this.player = new VlcControl();

            this.player.TimeChanged += (sender, e) => this.CheckSongFinished();
        }
        static bool Init(string path)
        {
            if (path == null)
            {
                if (!_timer.IsEnabled)
                {
                    _timer.Start();
                }
                return(false);
            }

            try
            {
                //Set libvlc.dll and libvlccore.dll directory path
                VlcContext.LibVlcDllsPath = path;
                //Set the vlc plugins directory path
                VlcContext.LibVlcPluginsPath = path + @"\plugins";

                if (debug)
                {
                    VlcContext.StartupOptions.LogOptions.LogInFile         = true;
                    VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
                    VlcContext.StartupOptions.LogOptions.Verbosity         = VlcLogVerbosities.Debug;
                }

                VlcContext.Initialize();
                InvokeVlcInitializedEvent();
                _timer.Stop();
                return(true);
            }
            catch (Exception)
            {
                if (!_timer.IsEnabled)
                {
                    _timer.Start();
                }
                return(false);
            }
        }
Example #25
0
        /// <summary>
        /// Pre Init all things need for VLC
        /// </summary>
        private void PreInitVlc()
        {
            //Set libvlc.dll and libvlccore.dll directory path
            VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_X86;
            //Set the vlc plugins directory path
            VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_X86;

            //switch to 64-bit mode
            //MessageBox.Show(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"VideoLAN\VLC"));
            //VlcContext.LibVlcDllsPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"VideoLAN\VLC");
            //VlcContext.LibVlcPluginsPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"VideoLAN\VLC\plugins");


            //Set the startup options
            //VlcContext.StartupOptions.IgnoreConfig = true;
            //VlcContext.StartupOptions.LogOptions.LogInFile = false;
            //VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;

            //Initialize the VlcContext
            VlcContext.Initialize();

            //create instance
            vlcPlayer = new VlcControl();
        }
 /// <summary>
 /// Main window closing event
 /// </summary>
 /// <param name="sender">Event sender. </param>
 /// <param name="e">Event arguments. </param>
 private void MainWindowOnClosing(object sender, CancelEventArgs e)
 {
     // Close the context.
     VlcContext.CloseAll();
 }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VlcPlayer"/> class.
        /// </summary>
        public MediaPlayer(string parameters, string callingPage)
        {
            _callingPage = callingPage;
            Messenger.Default.Register <KeyEventArgs>(this, MainWindow_KeyDown);

            if (Directory.Exists("C:\\Program Files\\VideoLAN\\VLC"))
            {
                // Set libvlc.dll and libvlccore.dll directory path
                VlcContext.LibVlcDllsPath = @"C:\Program Files\VideoLAN\VLC";

                // Set the vlc plugins directory path
                VlcContext.LibVlcPluginsPath = @"C:\Program Files\VideoLAN\VLC\plugins";
            }
            else
            {
                // Set libvlc.dll and libvlccore.dll directory path
                VlcContext.LibVlcDllsPath = @"C:\Program Files (x86)\VideoLAN\VLC";

                // Set the vlc plugins directory path
                VlcContext.LibVlcPluginsPath = @"C:\Program Files (x86)\VideoLAN\VLC\plugins";
            }



            /* Setting up the configuration of the VLC instance.
             * You can use any available command-line option using the AddOption function (see last two options).
             * A list of options is available at
             *     http://wiki.videolan.org/VLC_command-line_help
             * for example. */

            // Ignore the VLC configuration file
            VlcContext.StartupOptions.IgnoreConfig = true;

            // Enable file based logging
            VlcContext.StartupOptions.LogOptions.LogInFile = false;

            // Shows the VLC log console (in addition to the applications window)
            VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = false;

            // Set the log level for the VLC instance
            VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;

            // Disable showing the movie file name as an overlay
            VlcContext.StartupOptions.AddOption("--no-video-title-show");

            // Pauses the playback of a movie on the last frame
            //VlcContext.StartupOptions.AddOption("--play-and-pause");

            // Initialize the VlcContext
            VlcContext.Initialize();

            InitializeComponent();

            myVlcControl.VideoProperties.Scale = 2.0f;
            myVlcControl.PositionChanged      += VlcControlOnPositionChanged;
            myVlcControl.TimeChanged          += VlcControlOnTimeChanged;

            myVlcControl.Media = new PathMedia(parameters);
            myVlcControl.Media.ParsedChanged += MediaOnParsedChanged;
            myVlcControl.Play();
        }
Example #28
0
 private static void TakeDownVlcContext()
 {
     VlcContext.CloseAll();
 }
 public void ShutDown()
 {
     VlcContext.CloseAll();
 }
Example #30
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public override void Dispose()
 {
     this.player.Dispose();
     VlcContext.CloseAll();
 }