problem with mciSendString...

This is a discussion on problem with mciSendString... within the Windows Programming forums, part of the Platform Specific Boards category; Ok, well I dont get any error with this, and I haad everything working till I added the menu into ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    Unhappy problem with mciSendString...

    Ok, well I dont get any error with this, and I haad everything working till I added the menu into the mix, and as far as I can tell everything is pretty much in the right order of anyone can help me find my problem then I would be eternally grateful.
    Code:
    #include <iostream>
    #include <windows.h>
    #include <mmsystem.h>
    #include <string>
    using namespace std;
    int main()
    {
        int val = 1;
        do {
        val = 1;
        // Select file to play
        string f_name = "";
        string temp = "";
        bool pause = false;
        cout << "Type full file path if located in another folder, or type in file"
                "name if locatedin same folder as the executable. Use ""!"" as the"
                "terminating character e.x. \nC:\\Program Files\\LimeWire\\Korn.mp3!" << endl;
        cout << "File Name: ";
        getline( cin, f_name, '!' );
        cin.ignore();
        cout << endl;
        if ( val != 0 ) {
        cout << "If you want to pick a diffrent song just select RESET on menu after each song." << endl;
        cout << "Or REPLAY to start the song over. or EXIT to quit the program." << endl;
        cout << "Updates will probably include saved songed lists, and other helpful things." << endl;
        val = 0;
            }
        cout << endl;
        do {
        pause = false;
        temp = "open " + f_name;
        mciSendString ( f_name.c_str(), 0, 0, 0 );
        system("pause");
        temp = "play " + f_name;
        mciSendString ( f_name.c_str(), 0, 0, 0 );
        cout << "Now Playing: " << f_name << endl;
        cout << "Press Enter to display menu ( DOES NOT STOP THE SONG )" << endl;
        system("pause");
        cout << "1) Pause " << endl;
        cout << "2) Replay" << endl;
        cout << "3) Reset " << endl;
        cout << "4) Exit  " << endl;
        cout << "Selection: ";
        int tempi = 0;
        cin >> tempi;
        if ( tempi == 1 ) {
            pause = true;
            temp = "pause " + f_name;
            mciSendString ( f_name.c_str(), 0, 0, 0 );
            cout << "PRESS enter to Resume the song" << endl;
            temp = "resume " + f_name;
            mciSendString ( f_name.c_str(), 0, 0, 0 );
        }
        else if ( tempi == 2 ) {
            temp = "close " + f_name;
            mciSendString ( f_name.c_str(), 0, 0, 0 );
            temp = "open " + f_name;
            mciSendString ( f_name.c_str(), 0, 0, 0 );
            pause = true;
        }
        else if ( tempi == 3 ) {
            temp = "close " + f_name;
            mciSendString ( f_name.c_str(), 0, 0, 0 );
            pause = false;
            val = 0;
        }
        else {
            pause = false;
            val =1;
        }
            } while ( pause == true );
        } while ( val = 0 );
    }

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Looks like you're sending the wrong string to mciSendString - try it with 'temp' which you seem to be constructing from an mci command and a file path.

    By the way, you should really check the return values of these api functions. In this particular case, mciSendString returns zero on success or an error code on failure that can be used with mciGetErrorString to get some meaningful description of the error.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Yea, I had not made it that far yet, and I did not know the mci command to find the value, so mciGetErrorString will give me a value, can you demonstrate in a snippet please, thank you for any assistance. A stupid mistake on my part clearly. When I added the menu I rebuilt the loading of songs to allow me to clear them from memory and I had to change the vars to be able to select filename, and I just made a novice mistake, thank you for pointing it out though

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21