I am working on a console C# app where I want to get notified when an audio playing has finished and I am using winmm.dll
for all of this. But the only way I can find to get notified is using Windows.Forms
. As explained here and here.
Following is how I am playing an audio:
[DllImport("winmm.dll")]
static extern int mciSendString(string mciCommand, StringBuilder buffer, int bufferSize, IntPtr callback);
public string Play()
{
if (CurrentFile == null) CurrentFile = _playlist.FirstOrDefault();
if (CurrentFile != null)
{
Send("open " + _currentFileFullName);
Send("play " + _currentFileFullName);
return "Playing " + CurrentFile.Name;
}
else
{
return "No file to play";
}
}
Please suggest if there is any to get notified when playback has completed in a C# console application.