public override bool SetOutputContext(OutputContextType outputType) { if (VisualizationWindow == null) { return(false); } if (_Initialized && !firstRun) { return(true); } // If width or height are 0 the call to CreateVis will fail. // If width or height are 1 the window is in transition so we can ignore it. if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1) { return(false); } if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath)) { return(false); } if (_visParam.VisHandle != 0) { RenderStarted = false; int counter = 0; bool bFree = BassVis.BASSVIS_Free(_visParam); while ((!bFree) && (counter <= 10)) { bFree = BassVis.BASSVIS_IsFree(_visParam); System.Windows.Forms.Application.DoEvents(); counter++; } _visParam.VisHandle = 0; } try { //Remove existing CallBacks BassVis.BASSVIS_WINAMPRemoveCallback(); // Create the Visualisation BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath); visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex; visExec.AMP_UseOwnW1 = 1; visExec.AMP_UseOwnW2 = 1; BassVis.BASSVIS_ExecutePlugin(visExec, _visParam); if (_visParam.VisHandle != 0) { BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play); // Set the visualization window that was taken over from BASSVIS_ExecutePlugin BassVis.BASSVIS_SetVisPort(_visParam, _visParam.VisGenWinHandle, VisualizationWindow.Handle, 0, 0, VisualizationWindow.Width, VisualizationWindow.Height); // Set CallBack for PlayState _visCallback = BASSVIS_StateCallback; BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback); BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, 128); } // The Winamp Plugin has stolen focus on the MP window. Bring it back to froeground Win32API.SetForegroundWindow(GUIGraphicsContext.form.Handle); firstRun = false; } catch (Exception ex) { Log.Error( "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}", ex); } _Initialized = _visParam.VisHandle != 0; return(_visParam.VisHandle != 0); }
public override bool SetOutputContext(OutputContextType outputType) { if (VisualizationWindow == null) { return false; } if (_Initialized && !firstRun) { return true; } // If width or height are 0 the call to CreateVis will fail. // If width or height are 1 the window is in transition so we can ignore it. if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1) { return false; } if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath)) { return false; } if (_visParam.VisHandle != 0) { RenderStarted = false; int counter = 0; bool bFree = BassVis.BASSVIS_Free(_visParam); while ((!bFree) && (counter <= 10)) { bFree = BassVis.BASSVIS_IsFree(_visParam); System.Windows.Forms.Application.DoEvents(); counter++; } _visParam.VisHandle = 0; } try { //Remove existing CallBacks BassVis.BASSVIS_WINAMPRemoveCallback(); // Create the Visualisation BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath); visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex; visExec.AMP_UseOwnW1 = 1; visExec.AMP_UseOwnW2 = 1; BassVis.BASSVIS_ExecutePlugin(visExec, _visParam); if (_visParam.VisHandle != 0) { BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play); // Set the visualization window that was taken over from BASSVIS_ExecutePlugin BassVis.BASSVIS_SetVisPort(_visParam, _visParam.VisGenWinHandle, VisualizationWindow.Handle, 0, 0, VisualizationWindow.Width, VisualizationWindow.Height); // Set CallBack for PlayState _visCallback = BASSVIS_StateCallback; BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback); BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, 128); } // The Winamp Plugin has stolen focus on the MP window. Bring it back to froeground Win32API.SetForegroundWindow(GUIGraphicsContext.form.Handle); firstRun = false; } catch (Exception ex) { Log.Error( "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}", ex); } _Initialized = _visParam.VisHandle != 0; return _visParam.VisHandle != 0; }
public override bool SetOutputContext(OutputContextType outputType) { if (VisualizationWindow == null) { return false; } if (_Initialized && !firstRun) { return true; } // If width or height are 0 the call to CreateVis will fail. // If width or height are 1 the window is in transition so we can ignore it. if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1) { return false; } if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath)) { return false; } try { using (Profile.Settings xmlreader = new Profile.MPSettings()) { VizPluginInfo.FFTSensitivity = xmlreader.GetValueAsInt("musicvisualization", "fftSensitivity", 36); VizPluginInfo.PresetIndex = xmlreader.GetValueAsInt("musicvisualization", "preset", 0); } //Remove existing CallBacks BassVis.BASSVIS_WINAMPRemoveCallback(); // Call Play befor use BASSVIS_ExecutePlugin (moved here) BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play); // Set CallBack for PlayState _visCallback = BASSVIS_StateCallback; BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback); // Hide the Viswindow, so that we don't see it, befor any Render Win32API.ShowWindow(VisualizationWindow.Handle, Win32API.ShowWindowFlags.Hide); // Create the Visualisation BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath); visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex; visExec.AMP_UseOwnW1 = 1; visExec.AMP_UseOwnW2 = 1; // The flag below is needed for the Vis to have it's own message queue // Thus it is avoided that it steals focus from MP. visExec.AMP_UseFakeWindow = true; BassVis.BASSVIS_ExecutePlugin(visExec, _visParam); if (_visParam.VisHandle != 0) { // Set the visualization window that was taken over from BASSVIS_ExecutePlugin BassVis.BASSVIS_SetVisPort(_visParam, _visParam.VisGenWinHandle, VisualizationWindow.Handle, 0, 0, VisualizationWindow.Width, VisualizationWindow.Height); BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, VizPluginInfo.FFTSensitivity); // SetForegroundWindow GUIGraphicsContext.form.Activate(); } firstRun = false; } catch (Exception ex) { Log.Error( "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}", ex); } _Initialized = _visParam.VisHandle != 0; return _visParam.VisHandle != 0; }
public override bool SetOutputContext(OutputContextType outputType) { if (VisualizationWindow == null) { return(false); } if (_Initialized && !firstRun) { return(true); } // If width or height are 0 the call to CreateVis will fail. // If width or height are 1 the window is in transition so we can ignore it. if (VisualizationWindow.Width <= 1 || VisualizationWindow.Height <= 1) { return(false); } if (VizPluginInfo == null || VizPluginInfo.FilePath.Length == 0 || !File.Exists(VizPluginInfo.FilePath)) { return(false); } try { using (Profile.Settings xmlreader = new Profile.MPSettings()) { VizPluginInfo.FFTSensitivity = xmlreader.GetValueAsInt("musicvisualization", "fftSensitivity", 36); VizPluginInfo.PresetIndex = xmlreader.GetValueAsInt("musicvisualization", "preset", 0); } //Remove existing CallBacks BassVis.BASSVIS_WINAMPRemoveCallback(); // Call Play befor use BASSVIS_ExecutePlugin (moved here) BassVis.BASSVIS_SetPlayState(_visParam, BASSVIS_PLAYSTATE.Play); // Set CallBack for PlayState _visCallback = BASSVIS_StateCallback; BassVis.BASSVIS_WINAMPSetStateCallback(_visCallback); // Hide the Viswindow, so that we don't see it, befor any Render Win32API.ShowWindow(VisualizationWindow.Handle, Win32API.ShowWindowFlags.Hide); // Create the Visualisation BASSVIS_EXEC visExec = new BASSVIS_EXEC(VizPluginInfo.FilePath); visExec.AMP_ModuleIndex = VizPluginInfo.PresetIndex; visExec.AMP_UseOwnW1 = 1; visExec.AMP_UseOwnW2 = 1; // The flag below is needed for the Vis to have it's own message queue // Thus it is avoided that it steals focus from MP. visExec.AMP_UseFakeWindow = true; BassVis.BASSVIS_ExecutePlugin(visExec, _visParam); if (_visParam.VisHandle != 0) { // Set the visualization window that was taken over from BASSVIS_ExecutePlugin BassVis.BASSVIS_SetVisPort(_visParam, _visParam.VisGenWinHandle, VisualizationWindow.Handle, 0, 0, VisualizationWindow.Width, VisualizationWindow.Height); BassVis.BASSVIS_SetOption(_visParam, BASSVIS_CONFIGFLAGS.BASSVIS_CONFIG_FFTAMP, VizPluginInfo.FFTSensitivity); // SetForegroundWindow GUIGraphicsContext.form.Activate(); } firstRun = false; } catch (Exception ex) { Log.Error( "Visualization Manager: Winamp visualization engine initialization failed with the following exception {0}", ex); } _Initialized = _visParam.VisHandle != 0; return(_visParam.VisHandle != 0); }