public static void PlayAMp3(string args) { graphManager = new QuartzTypeLib.FilgraphManager(); mp3control = (QuartzTypeLib.IMediaControl)graphManager; mp3control.RenderFile(args); mp3control.Run(); }
private void ReleaseUnmangedResources() { try { if (_quartzVideo != null) { _quartzVideo.Owner = -1; } } catch { } if (_quartzFilgraphManager != null) { try { _quartzFilgraphManager.Stop(); Marshal.ReleaseComObject(_quartzFilgraphManager); _quartzFilgraphManager = null; } catch { } } _quartzVideo = null; }
/// <summary> /// This method plays the audio-file which is specified in the parameter "filename". /// Unit Test necessary /// </summary> /// <param name="filename">filename of audio-file</param> /// <param name="wait_until_finished">boolean variable</param> /// <returns>true or false</returns> /// <remarks>Documented by Dev04, 2007-07-19</remarks> public bool Play(string filename, bool wait_until_finished) { filename = filename.Replace("/", "\\"); try { if (wait_until_finished) Wait(); else if (StreamInfo != null) mp3control.Stop(); graphManager = new QuartzTypeLib.FilgraphManager(); mp3control = (QuartzTypeLib.IMediaControl)graphManager; mp3control.RenderFile(filename); mp3control.Run(); System.Diagnostics.Trace.WriteLine("Started playing " + filename); StreamInfo = (QuartzTypeLib.IMediaPosition)graphManager; System.Diagnostics.Trace.WriteLine("Streaminfo currentposition: " + StreamInfo.CurrentPosition.ToString() + " stoptime: " + StreamInfo.StopTime.ToString()); return true; } catch (Exception exp) { Trace.WriteLine(exp.ToString()); return false; } }
private void SetSource(string FileName) { try { State = ContainerState.CS_Empty; FilterGraph = new DS.FilgraphManager(); FilterGraph.RenderFile(FileName); VideoWindow = FilterGraph as DS.IVideoWindow; MediaControl = FilterGraph as DS.IMediaControl; ScanGraph(); State = ContainerState.CS_Connected; } catch (COMException ex) { if (EventConsumer != null) { return; } string ErrorLine = null; bool Internal = GetErrorDescription(out ErrorLine); if (Internal) { throw new VideoException(ErrorLine); } else { throw new VideoException(string.Format("General AV error #{0:X08}, please check MSDN", (uint)ex.ErrorCode), ex); } } }
private void SetSource(string FileName) { try { FilterGraph = new DS.FilgraphManager(); try { FilterGraph.RenderFile(FileName); } catch (Exception ex) { throw (ex is COMException ? ex : new COMException(ex.Message)); } if (UseVideo) { VideoWindow = FilterGraph as DS.IVideoWindow; } MediaControl = FilterGraph as DS.IMediaControl; ScanGraph(); } catch (COMException ex) { // if (EventConsumer != null) return; ??? why is it here? string ErrorLine = null; System.Threading.Thread.Sleep(1000); } }
/// <summary> /// This method plays the audio-file which is specified in the parameter "filename". /// Unit Test necessary /// </summary> /// <param name="filename">filename of audio-file</param> /// <param name="wait_until_finished">boolean variable</param> /// <returns>true or false</returns> /// <remarks>Documented by Dev04, 2007-07-19</remarks> public bool Play(string filename, bool wait_until_finished) { filename = filename.Replace("/", "\\"); try { if (wait_until_finished) { Wait(); } else if (StreamInfo != null) { mp3control.Stop(); } graphManager = new QuartzTypeLib.FilgraphManager(); mp3control = (QuartzTypeLib.IMediaControl)graphManager; mp3control.RenderFile(filename); mp3control.Run(); System.Diagnostics.Trace.WriteLine("Started playing " + filename); StreamInfo = (QuartzTypeLib.IMediaPosition)graphManager; System.Diagnostics.Trace.WriteLine("Streaminfo currentposition: " + StreamInfo.CurrentPosition.ToString() + " stoptime: " + StreamInfo.StopTime.ToString()); return(true); } catch (Exception exp) { Trace.WriteLine(exp.ToString()); return(false); } }
private void DisposeQuarts(object player) { try { if (_quartzVideo != null) { _quartzVideo.Owner = -1; } } catch { } if (_quartzFilgraphManager != null) { try { _quartzFilgraphManager.Stop(); Marshal.ReleaseComObject(_quartzFilgraphManager); } catch { } } _quartzFilgraphManager = null; _quartzVideo = null; }
internal DS_Audio(string Archivo) { mediaControl = new QuartzTypeLib.FilgraphManager(); mediaControl.RenderFile(Archivo); audioBasico = (QuartzTypeLib.IBasicAudio)mediaControl; mediaEvento = (QuartzTypeLib.IMediaEvent)mediaControl; mediaPosicion = (QuartzTypeLib.IMediaPosition)mediaControl; }
private void Play() { QuartzTypeLib.FilgraphManager mc = new QuartzTypeLib.FilgraphManager(); try { mc.RenderFile("pow.wav"); mc.Run(); } catch { } }
public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) { const int wsChild = 0x40000000; string ext = System.IO.Path.GetExtension(videoFileName).ToLower(); bool isAudio = ext == ".mp3" || ext == ".wav" || ext == ".wma" || ext == ".m4a"; OnVideoLoaded = onVideoLoaded; OnVideoEnded = onVideoEnded; VideoFileName = videoFileName; _owner = ownerControl; _quartzFilgraphManager = new FilgraphManager(); _quartzFilgraphManager.RenderFile(VideoFileName); if (!isAudio) { _quartzVideo = _quartzFilgraphManager as IVideoWindow; _quartzVideo.Owner = (int)ownerControl.Handle; _quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height); _quartzVideo.WindowStyle = wsChild; } //Play(); if (!isAudio) { (_quartzFilgraphManager as IBasicVideo).GetVideoSize(out _sourceWidth, out _sourceHeight); } _owner.Resize += OwnerControlResize; _mediaPosition = (IMediaPosition)_quartzFilgraphManager; if (OnVideoLoaded != null) { _videoLoader = new BackgroundWorker(); _videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted; _videoLoader.DoWork += VideoLoaderDoWork; _videoLoader.RunWorkerAsync(); } OwnerControlResize(this, null); _videoEndTimer = new Timer { Interval = 500 }; _videoEndTimer.Tick += VideoEndTimerTick; _videoEndTimer.Start(); if (!isAudio) { _quartzVideo.MessageDrain = (int)ownerControl.Handle; } }
private void tsmiabout_Click(object sender, EventArgs e2) { rover.Play("Writing"); QuartzTypeLib.FilgraphManager mc = new QuartzTypeLib.FilgraphManager(); try { mc.RenderFile("about.mp3"); mc.Run(); about.ShowDialog(); mc.Stop(); } catch { about.ShowDialog(); // MessageBox.Show( e.Message + " " + e.Source + " " + e.StackTrace ); } }
/// <summary> /// This method stops the current playback of a sound. /// No Unit Test necessary /// </summary> /// <remarks>Documented by Dev04, 2007-07-19</remarks> public void StopPlaying() { if (StreamInfo != null) { try { mp3control.Stop(); Marshal.ReleaseComObject(mp3control); mp3control = null; Marshal.ReleaseComObject(StreamInfo); StreamInfo = null; Marshal.ReleaseComObject(graphManager); graphManager = null; } catch { } } }
public void Clear() { Stop(); if (VideoWindow != null) { VideoWindow.Visible = 0; } FileValid = false; TestControl = null; MediaControl = null; VideoWindow = null; FilterGraph = null; if (omsdFileName != null) { System.IO.File.Delete(omsdFileName); FileValid = false; } State = ContainerState.CS_Empty; }
public void Clear(bool doStop) { if (doStop) { if (TestControl != null) { TestControl.StopActivity(); } if (MediaControl != null) { if (!UseToTerminate) { MediaControl.Stop(); } } } if (VideoWindow != null) { VideoWindow.Visible = 0; } FileValid = false; TestControl = null; MediaControl = null; VideoWindow = null; try { if (FilterGraph != null) { Marshal.ReleaseComObject(FilterGraph); } } catch (Exception) { } FilterGraph = null; ClearName(); }
private void cmdOpen_Click(object sender, EventArgs e) { // Allow the user to choose a file. OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Media Files|*.wav;*.mp3;*.mp2;*.wma|All Files|*.*"; if (DialogResult.OK == openFileDialog.ShowDialog()) { // Access the IMediaControl interface. QuartzTypeLib.FilgraphManager graphManager = new QuartzTypeLib.FilgraphManager(); QuartzTypeLib.IMediaControl mc = (QuartzTypeLib.IMediaControl)graphManager; // Specify the file. mc.RenderFile(openFileDialog.FileName); // Start playing the audio asynchronously. mc.Run(); } }
private void DisposeQuarts(object player) { try { if (_quartzVideo != null) _quartzVideo.Owner = -1; } catch { } if (_quartzFilgraphManager != null) { try { _quartzFilgraphManager.Stop(); Marshal.ReleaseComObject(_quartzFilgraphManager); } catch { } } _quartzFilgraphManager = null; _quartzVideo = null; }
public void OpenFileFunc() { ReLoad(); string openedfile = textBox1.Text; m_obj_FilterGraph = new FilgraphManager(); try { m_obj_FilterGraph.RenderFile(openedfile); } catch (Exception) { MessageBox.Show("Please choose a valid file.\n Check the file path.\n File path could be changed."); return; } try { m_obj_BasicAudio = m_obj_FilterGraph as QuartzTypeLib.IBasicAudio; m_obj_BasicAudio.Volume = trackBar1.Value; } catch { } try { m_obj_VideoWindow = m_obj_FilterGraph as QuartzTypeLib.IVideoWindow; m_obj_VideoWindow.Owner = (int)panel1.Handle; m_obj_VideoWindow.WindowStyle = WS_CHILD; m_obj_VideoWindow.SetWindowPosition(panel1.ClientRectangle.Left, panel1.ClientRectangle.Top, panel1.ClientRectangle.Right, panel1.ClientRectangle.Bottom); videoplaying = true; timer1.Start(); } catch (Exception) { m_obj_VideoWindow = null; videoplaying = false; } if (videoplaying) { trackBar1.Enabled = true; timer1.Start(); } else { MessageBox.Show("Choose a Valid Video File"); } running = true; m_obj_MediaEvent = m_obj_FilterGraph as QuartzTypeLib.IMediaEvent; m_obj_MediaEventEx = m_obj_FilterGraph as QuartzTypeLib.IMediaEventEx; m_obj_MediaEventEx.SetNotifyWindow((int)this.Handle, WM_GRAPHNOTIFY, 0); m_obj_MediaPosition = m_obj_FilterGraph as QuartzTypeLib.IMediaPosition; m_obj_MediaControl = m_obj_FilterGraph as QuartzTypeLib.IMediaControl; trackBar1.Maximum = (int)m_obj_MediaPosition.Duration; trackBar1.Minimum = 0; trackBar1.Value = (int)m_obj_MediaPosition.CurrentPosition; m_obj_MediaControl.Run(); m_CurrentStatus = MediaStatus.Running; this.Refresh(); UpdateToolStrip(); }
private void ReleaseUnmangedResources() { try { if (_quartzVideo != null) _quartzVideo.Owner = -1; } catch { } if (_quartzFilgraphManager != null) { try { _quartzFilgraphManager.Stop(); Marshal.ReleaseComObject(_quartzFilgraphManager); _quartzFilgraphManager = null; } catch { } } _quartzVideo = null; }
public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded) { const int wsChild = 0x40000000; string ext = System.IO.Path.GetExtension(videoFileName).ToLower(); bool isAudio = ext == ".mp3" || ext == ".wav" || ext == ".wma" || ext == ".m4a"; OnVideoLoaded = onVideoLoaded; OnVideoEnded = onVideoEnded; VideoFileName = videoFileName; _owner = ownerControl; _quartzFilgraphManager = new FilgraphManager(); _quartzFilgraphManager.RenderFile(VideoFileName); if (!isAudio) { _quartzVideo = _quartzFilgraphManager as IVideoWindow; _quartzVideo.Owner = (int)ownerControl.Handle; _quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height); _quartzVideo.WindowStyle = wsChild; } //Play(); if (!isAudio) (_quartzFilgraphManager as IBasicVideo).GetVideoSize(out _sourceWidth, out _sourceHeight); _owner.Resize += OwnerControlResize; _mediaPosition = (IMediaPosition)_quartzFilgraphManager; if (OnVideoLoaded != null) { _videoLoader = new BackgroundWorker(); _videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted; _videoLoader.DoWork += VideoLoaderDoWork; _videoLoader.RunWorkerAsync(); } OwnerControlResize(this, null); _videoEndTimer = new Timer { Interval = 500 }; _videoEndTimer.Tick += VideoEndTimerTick; _videoEndTimer.Start(); if (!isAudio) _quartzVideo.MessageDrain = (int)ownerControl.Handle; }
//PLAYER ý yeniden yükleme iþlemi.... public void ReLoad() { if (m_obj_MediaControl != null) { m_obj_MediaControl.Stop(); m_CurrentStatus = MediaStatus.Stopped; } if (m_obj_MediaEventEx != null) m_obj_MediaEventEx.SetNotifyWindow(0, 0, 0); if (m_obj_VideoWindow != null) { m_obj_VideoWindow.Visible = 0; m_obj_VideoWindow.Owner = 0; } if (m_obj_MediaControl != null) m_obj_MediaControl = null; if (m_obj_MediaPosition != null) m_obj_MediaPosition = null; if (m_obj_MediaEventEx != null) m_obj_MediaEventEx = null; if (m_obj_MediaEvent != null) m_obj_MediaEvent = null; if (m_obj_VideoWindow != null) m_obj_VideoWindow = null; if (m_obj_BasicAudio != null) m_obj_BasicAudio = null; if (m_obj_FilterGraph != null) m_obj_FilterGraph = null; UpdateToolStrip(); timer1.Stop(); running = false; }
private void StartForm_Load(object sender, System.EventArgs e) { this.fgm = new FilgraphManager(); this.fileNameTextBox.Text = Path.Combine(Application.StartupPath, "PPK - Resurection Space Club Remix.mp3"); openFileDialog.Filter = "Sounddateien|*.mp3;*.wav|Videodateien|*.avi;*.mpg;*.mpeg|Alle Dateien|*.*"; }
}//ConfigurationFile(). ///<summary>Static.</summary> static UtilityQuartz() { filgraphManager = new QuartzTypeLib.FilgraphManager(); mediaControl = (QuartzTypeLib.IMediaControl) filgraphManager; }//static UtilityQuartz()