DarkAtom
DarkAtom

Reputation: 3161

mciSendString check if music is playing

I have an application that uses the mciSendString function to play mp3 files. The function that starts playing music is this one:

void PlayMp3(std::string name)
{
    std::string command = "open " + name + " type mpegvideo";
    mciSendString(command.c_str(), NULL, 0, 0);
    command = "play " + name;
    mciSendString(command.c_str(), NULL, 0, 0);
}

How can I check at a given moment if a music file is being played? I want to create a function Mp3IsPlaying() that returns true if music is being played and false if it isn't.

Upvotes: 0

Views: 468

Answers (1)

XectX
XectX

Reputation: 36

Based on: https://www.codeproject.com/Articles/63094/Simple-MCI-Player

You would write something like this:

void Mp3IsPlaying(std::string name)
{
    std::string command = "status " + name + " mode";
    char status[128] = {};
    mciSendString(command.c_str(), status, 128, 0);
    return (strcmp(status, "playing") == 0);
}

Upvotes: 1

Related Questions