本文整理汇总了C#中Audio.Open方法的典型用法代码示例。如果您正苦于以下问题:C# Audio.Open方法的具体用法?C# Audio.Open怎么用?C# Audio.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audio
的用法示例。
在下文中一共展示了Audio.Open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open_Click
private void Open_Click(object sender, EventArgs e)
{
//Open a dialog box to search for a track
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "MP3|*.mp3|WAV|*.wav"; //only search for mp3's and wav's
ofd.Title = "Select and audio track to play"; //Change the title of the dialog box
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Filepath.Text = ofd.FileName; //Filepath
mPlayer = new Audio(Filepath.Text); //Tells the player the filepath of the track
mPlayer.Open(Filepath.Text, false); //Opens the file
trackbarControl(); //Sets Minimum/Maximum length for the trackbar equal to audio length
audio_filename.Text = ofd.SafeFileName; //Shows the name of the track
//Get the max length of the audio track
TimeSpan soundLength = TimeSpan.FromSeconds((int)mPlayer.Duration);
trackbar_maxTime.Text = soundLength.ToString();
//Set trackbar and info to show
setPlayerInfoVisibility(true);
}
}