Example #1
0
        /// <summary>
        /// Create new instance of MVPlayer control.
        /// </summary>
        public MVPlayer()
        {
            InitializeComponent();

            if ((LicenseManager.UsageMode == LicenseUsageMode.Runtime))
            {
                if (!MV_Manager.IsInitialized)
                {
                    throw new InvalidOperationException("MediaVault library is not initialized! Call MV_Manager.InitilizeMediaVault() before using this control in runtime!");
                }

                if (MV_Manager.GetMVLibDLL() == null)
                {
                    throw new NullReferenceException("Unable to obtain loaded MVLib! Are you sure initialization was succeeded?");
                }

                IsInDesignMode = false;

                Type mvlibWrapperType = null;

                foreach (Type type in MV_Manager.GetMVLibDLL().GetExportedTypes())
                {
                    if (type.Name == MVLIB_WRAPPER_TYPE)
                    {
                        mvlibWrapperType = type;
                        break;
                    }
                }

                if (mvlibWrapperType == null)
                {
                    throw new InvalidOperationException("Unable to find MVLibWrapper class in loaded assemblies! Check if you dependencies are correct!\n Please visit https://github.com/Kuba-MV/MVLib-DotNet if you need to download additional dependencies!");
                }

                _media_wrapper = Activator.CreateInstance(mvlibWrapperType);

                if (_media_wrapper == null)
                {
                    throw new InvalidOperationException("Unable to create MVLibWrapper instance. Check if your dependencies are correct!");
                }

                _media_wrapper.CreateD3DHwndRenderer(pnD3D.Handle);
            }
            else
            {
                IsInDesignMode = true;
            }

            if (!IsInDesignMode)
            {
                InstallInRenderLoop();
            }
        }
Example #2
0
        /// <summary>
        /// Creates new instance of Media Vault Library Control for WPF
        /// </summary>
        public MVPlayer()
        {
            InitializeComponent();

            if ((LicenseManager.UsageMode == LicenseUsageMode.Runtime))
            {
                if (!MV_Manager.IsInitialized)
                {
                    throw new InvalidOperationException("MediaVault library is not initialized! Call MV_Manager.InitilizeMediaVault() before using this control in runtime!");
                }

                if (MV_Manager.GetMVLibDLL() == null)
                {
                    throw new NullReferenceException("Unable to obtain loaded MVLib! Are you sure initialization was succeeded?");
                }

                Type mvlibWrapperType = null;

                foreach (Type type in MV_Manager.GetMVLibDLL().GetExportedTypes())
                {
                    if (type.Name == MVLIB_WRAPPER_TYPE)
                    {
                        mvlibWrapperType = type;
                        break;
                    }
                }

                if (mvlibWrapperType == null)
                {
                    throw new InvalidOperationException("Unable to find MVLibWrapper class in loaded assemblies! Check if you dependencies are correct!\nPlease visit https://github.com/Kuba-MV/MVLib-DotNet if you need to download additional dependencies!");
                }

                _media_wrapper = Activator.CreateInstance(mvlibWrapperType);

                if (_media_wrapper == null)
                {
                    throw new InvalidOperationException("Unable to create MVLibWrapper instance. Check if your dependencies are correct!");
                }

                _media_wrapper.CreateD3DOffScreenRenderer();

                _d3d_render = new D3DImage();
                _d3d_render.IsFrontBufferAvailableChanged += _d3d_render_IsFrontBufferAvailableChanged;

                videoImage.Source = _d3d_render;

                CompositionTarget.Rendering += CompositionTarget_Rendering;
            }
        }