こんにちは、次のコードを書きましたが、 「dataGridView1_CellClick」イベント を離れた後、オーディオ ファイルを再生するのは 1 回だけです。私は知りたいです:
1) イベント内で音を出すことはできますか?
2) "Player.settings.playCount"を使用せずにブロードキャストを繰り返すことはできますか? このコードは、各ファイルのリリース前に遅らせることができないためです。ありがとう
私のコードは:
WMPLib.WindowsMediaPlayer Player = new WMPLib.WindowsMediaPlayer();
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
//...
//********** Play audio of Word
// sVoicePath = @"C:\4536.mp3"
sVoicePath = Application.StartupPath + dataGridView1.CurrentRow.Cells[4].Value.ToString();
PlayFile(sVoicePath);
//...
}
//*****************************
private void PlayFile(String url)
{
for (int i = 0; i < 3 ;i++)
{
System.Threading.Thread.Sleep(2000);
Player.URL = url;
Player.controls.play();
}
}
//*****************************
private void Player_PlayStateChange(int NewState)
{
if ((WMPLib.WMPPlayState)NewState ==
WMPLib.WMPPlayState.wmppsStopped)
{
//Actions on stop
}
}