/// <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 PlayAMp3(string args) { graphManager = new QuartzTypeLib.FilgraphManager(); mp3control = (QuartzTypeLib.IMediaControl)graphManager; mp3control.RenderFile(args); mp3control.Run(); }
}//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()
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(); } }