0

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.

Community
  • 1
  • 1
lbrahim
  • 3,710
  • 12
  • 57
  • 95
  • can you get the audio length? – Slashy Sep 20 '15 at 19:18
  • @Slashy That is my second option. I can get the length using [status](https://msdn.microsoft.com/en-us/library/ms713277%28v=vs.85%29.aspx) but not sure in what unit it is returning the length. – lbrahim Sep 20 '15 at 19:46

0 Answers0