I want to play an mp3 file using the command system("start name.mp3");
from <windows.h>
.
Every time I get the same error "The system cannot find the file name.mp3", and I know I have a file called name.mp3, so can anyone help?
Asked
Active
Viewed 106 times
-5
-
Is the file name.mp3 in the same directory than your exe file? – Rockcat Dec 25 '20 at 18:57
-
Yes it is...... – IDK Dec 25 '20 at 19:00
-
1name.mp3 is in same directory you are executing the command? For instance if you are executing the programa ```program.exe``` it is, if you are executing ```Debug/program.exe``` it isn't. Try to execute in the command line, not in a IDE. – Matheus Rossi Saciotto Dec 25 '20 at 22:02
-
If that's Windows specific, you can use [`ShellExecute[Ex]`](https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea) directly, see for example [How can you open a file with the program associated with its file extension?](https://stackoverflow.com/questions/9115574/how-can-you-open-a-file-with-the-program-associated-with-its-file-extension). – dxiv Dec 25 '20 at 22:42
1 Answers
0
Try this
system("\"name.mp3\"") ;
Make sure its in the same folder as the software.

Saifeddine Ben Salem
- 147
- 9