How to play mp3 file in vlc with c ++

I need to write C ++ code that plays a specific song in VLC. I did some research but I didn't find too many.

#include <iostream>
#include <string>
//#include "VLCWrapper.h"
//#include<libvlccore.dll>
//#include<libvlc.dll>
using namespace std;
int main() 
{

    cout << "Welcome to VLC launcher program!" << endl;
    cout << "Please enter a filename: ";
    string filename;
    getline(cin, filename);

    string comm = "vlc \"";
    comm += filename + "\"";
    system(comm.c_str()); //call VLC with the file "filename"
    return 0;
 }

      

This is what I found, but when I compile, "vlc" is not recognized as an internal or external command executable or batch file. I need help please.

+3


source to share


1 answer


You most likely have no path vlc

in the path, since when I compile it

(should have added this)

#include <cstdlib>

      

it works fine (I compiled it with g++

):



$ ./a.out 
Welcome to VLC launcher program!
Please enter a filename: Darkside.mp4
VLC media player 2.1.5 Rincewind (revision 2.1.4-49-gdab6cb5)
[0x1888a58] pulse audio output error: PulseAudio server connection failure: Connection refused
[0x1770028] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
[0x7f8288001248] main vout display error: Failed to resize display

You can try replacing vlc

with full path (for example /usr/bin/vlc

) ...

In case you are on Windows (you have bad ones) it will be the same, just Google is not an internal or external team, and there will be some advice on how to fix it.

Also, you will need vlc.exe

, perhaps I have never used the command line on Windows, so not sure how it works there.

0


source







All Articles