示例#1
0
        public override bool Initialize()
        {
            bool result = false;

            try
            {
                Log.Info("  Visualization Manager: Initializing WMP visualization...");

                RECT rect = new RECT();
                rect.left   = 0;
                rect.top    = 0;
                rect.right  = VisualizationWindow.Width;
                rect.bottom = VisualizationWindow.Height;

                OutputContextType outputType = VisualizationWindow.OutputContextType;
                result = WMPInterop.InitWMPEngine(VizPluginInfo.CLSID, VizPluginInfo.PresetIndex, OutputContextType.WindowHandle,
                                                  IntPtr.Zero,
                                                  VisualizationWindow.Handle, ref rect);
                _Initialized = result;
                Log.Info("  Visualization Manager: WMP visualization initialization {0}", (result ? "succeeded." : "failed!"));
            }

            catch (Exception ex)
            {
                Console.WriteLine("CreateGForceVisualization failed with the following exception: {0}", ex);
                Log.Error(
                    "  Visualization Manager: WMP visualization engine initialization failed with the following exception {0}", ex);
                return(false);
            }

            return(result);
        }
示例#2
0
        public override int RenderVisualization()
        {
            if (VisualizationWindow.InvokeRequired)
            {
                ThreadSafeRenderDelegate d = new ThreadSafeRenderDelegate(RenderVisualization);
                return((int)VisualizationWindow.Invoke(d));
            }

            RECT rect = new RECT();

            rect.left   = 0;
            rect.top    = 0;
            rect.right  = VisualizationWindow.Width;
            rect.bottom = VisualizationWindow.Height;

            TimedLvl.waveform  = new byte[2048];
            TimedLvl.frequency = new byte[2048];
            TimedLvl.State     = (int)WMPInterop.AudioState.Playing;

            bool gotWaveData = GetWaveData(ref TimedLvl.waveform);
            bool gotfreqData = GetFftData(ref TimedLvl.frequency);

            IntPtr pTimedLevel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(WMPInterop.TimedLevel)));

            Marshal.StructureToPtr(TimedLvl, pTimedLevel, false);

            int result = 0;

            result = WMPInterop.RenderWMP(pTimedLevel, ref rect);

            Marshal.FreeHGlobal(pTimedLevel);
            return(result);
        }
示例#3
0
        public override bool SetOutputContext(OutputContextType outputType)
        {
            if (VisualizationWindow == null)
            {
                return(false);
            }

            // If width or height are 0 the call will fail.  If width or height are 1 the window is in transition
            if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1)
            {
                return(false);
            }

            bool result = WMPInterop.SetOutputWMP(outputType, VisualizationWindow.Handle);

            return(result);
        }