/// <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; } }
/// <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); } }
}//public static void Main(string[] args) ///<summary>QuartzPlay.</summary> ///<param name="filename">Filename.</param> ///<param name="exceptionMessage">Exception message.</param> public static void QuartzPlay ( ref string[] filename, ref string exceptionMessage ) { try { foreach( string filenameCurrent in filename ) { System.Console.WriteLine("Filename: {0}", filenameCurrent); mediaControl.RenderFile( filenameCurrent ); mediaControl.Run(); System.Console.WriteLine("Press Enter to continue."); System.Console.ReadLine(); }//foreach( string filenameCurrent in filename ) }//try catch (System.Exception exception) { exceptionMessage = exception.Message; System.Console.WriteLine("Exception: {0}", exception.Message); } }//public static void QuartzPlay()
public static void PlayAMp3(string args) { graphManager = new QuartzTypeLib.FilgraphManager(); mp3control = (QuartzTypeLib.IMediaControl)graphManager; mp3control.RenderFile(args); mp3control.Run(); }
public void Run() { if (!((State == ContainerState.CS_Connected) || (State == ContainerState.CS_Stopped))) { return; } if ((TestControl == null) || (MediaControl == null)) { throw new VideoException("Internal error in AV engine"); } Exception ex = null; Action RunAction = new Action(() => { try { TestControl.ControlStream(1); MediaControl.Run(); State = ContainerState.CS_Running; } catch (Exception e) { ex = e; } }); IAsyncResult RunResult = RunAction.BeginInvoke(null, null); if (RTSP) { ProceedAction(step_SETUP, step_WaitStream, RunResult, ref ex); } else { // skip SETUP and PLAY steps ProceedAction(step_WaitStream, step_WaitStream, RunResult, ref ex); } }
public void Run() { if (!((State == ContainerState.CS_Connected) || (State == ContainerState.CS_Stopped))) { return; } if ((TestControl == null) || (MediaControl == null)) { throw new VideoException("Internal error in AV engine"); } Exception ex = null; Action RunAction = new Action(() => { try { TestControl.ControlStream(1); MediaControl.Run(); State = ContainerState.CS_Running; } catch (Exception e) { ex = e; } }); IAsyncResult RunResult = RunAction.BeginInvoke(null, null); #if true ProceedAction(6, 8, RunResult, ref ex); #else if (EventConsumer != null) { LogActivity(Timeout, 6, 8, RunResult); } else { RunResult.AsyncWaitHandle.WaitOne(Timeout); } if (!RunResult.IsCompleted) { throw new VideoException("Connection Timeout"); } if (ex != null) { ProceedEx(ex); //throw ex; } #endif }
public void Run() { if (TestControl == null) { SilentRun(); return; } UseToTerminate = false; Failed = false; FailedText = null; MediaControl.Run(); int Activity = 0; InLongCycle = true; do { System.Threading.Thread.Sleep(100); if (TestControl != null) { TestControl.GetActivity(ref Activity); } ; if (UseToTerminate) { if (TestControl != null) { TestControl.StopActivity(); } ; } }while (Activity != 0); InLongCycle = false; if (UseToTerminate) { throw (new StopEventException("Halt button used")); } if (Failed) { throw (new VideoException(FailedText)); } }
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(); } }
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(); }