I am aiming to build an audio player that plays MP3 files. For that, I have used the mciSendString()
function. All the MP3 files are in the same folder as the main source file. I have looked at the documentation and some syntax online, despite that I am unable to play the MP3 files. When I select a song, it doesn't play, and the code skips to system("pause")
.
My header files
#include <iostream>
#include <windows.h>
#include <conio.h>
#pragma comment(lib, "Winmm.lib")
using namespace std;
Function that plays the MP3 files:
void playsong()
{
int song;
system("cls");
cout << "****************************" << endl;
cout << "\tPLAYING SONG\n";
cout << "****************************" << endl;
cout << "List of Songs\n";
cout << "1.0\n";
cout << "2.AFSANAY\n";
cout << "3.Agency\n";
cin >> song;
switch(song)
{
case 1:
{
mciSendString("open \"C:\\Users\Murad\Documents\3rd Semester\OOP\Assignments\Assignmnet 1\Assignmnet 1\0.mp3\" type mpegvideo alias mp3", NULL, 0, NULL);
mciSendString("play mp3", NULL, 0, NULL);
break;
}
case 2:
{
mciSendString("open \"C:\\Users\Murad\Documents\3rd Semester\OOP\Assignments\Assignmnet 1\Assignmnet 1\AFSANAY.mp3\" type mpegvideo alias mp3", NULL, 0, NULL);
mciSendString("play mp3", NULL, 0, NULL);
break;
}
case 3:
{
mciSendString("open \"C:\\Users\Murad\Documents\3rd Semester\OOP\Assignments\Assignmnet 1\Assignmnet 1\Agency.mp3\" type mpegvideo alias mp3", NULL, 0, NULL);
mciSendString("play mp3", NULL, 0, NULL);
break;
}
}
system("pause");
system("cls");
display();
}