Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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;
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor of VlcControl
        /// </summary>
        public VlcControl()
        {
            if (!Application.Current.IsRunningOutOfBrowser)
                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.BeginInvoke(singleInvoke, sender, arg);

                };
            InitEvents();

            myVideoLockCallback = LockCallback;
            myVideoLockCallbackHandle = GCHandle.Alloc(myVideoLockCallback);
            //myVideoUnlockCallback = UnlockCallback;
            //myVideoUnlockCallbackHandle = GCHandle.Alloc(myVideoUnlockCallback);
            myDisplayCallback = DisplayCallback;
            myDisplayCallbackHandle = GCHandle.Alloc(myDisplayCallback);

            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, myDisplayCallback, IntPtr.Zero);
        }
        /// <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;
        }