problem with c++, mplayer interface.
anyone with c++ and mplayer knowledge know whats wrong with this?
Code:
#include <string.h>
#include <iostream>
#include <fstream>
class mplayer_interface
{
private:
FILE *mp_pipe;
public:
void setup()
{
mp_pipe = popen("mplayer -slave -quiet -idle &> /dev/null", "w");
}
void close()
{
pclose(mp_pipe);
}
void play( )
{
fputs("loadlist ./data/.currentplaylist\n", mp_pipe);
}
void stop()
{
fputs("stop\n", mp_pipe);
}
};
void cd_to_exe_dir( char *argv[] )
{
std::string path = argv[0];
int ii = path.length();
while ( !( path[ii] == '/' || path[ii] == '\\' ) )
{
ii--;
}
path.erase( ii, 100 );
chdir( path.c_str() );
}
int main( int argc, char *argv[] )
{
cd_to_exe_dir( argv );
mplayer_interface mplayer;
mplayer.setup();
mplayer.play();
std::string userI;
while ( strcmp( userI.c_str(), "exit") != 0 )
{
std::cout<<'>';
std::cin>>userI;
}
mplayer.stop();
mplayer.close();
return(0);
}
nothing plays until i type exit, then mplayer plays the first half second of the first file in ./data/.currentplaylist. i want it to play until exit is typed.