Thread: problem with c++, mplayer interface.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    29

    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.
    Last edited by IM back!; 02-20-2010 at 08:24 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. Replies: 1
    Last Post: 03-03-2006, 12:22 PM
  3. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM