Menu

playing sounds and opening external files

2007-09-17
2012-09-26
  • Martian Man

    Martian Man - 2007-09-17

    Hi, I want to play basically all sound files. Like mp3, m4a, m4p, wav, wma, mp2, mpeg... I've used so many options to play mp3s but I can't do it. I've tried mciSendString, PlaySound, ShellExecute, and sndPlaySound. But none of them works. idk if I've done any or all of them correctly of them correctly. Could someone please tell me more ways to do it and give me the code for all of those and for the all one's I've mentioned. (Basically tell me more and correct me if I'm doing the one's below wrong. I want to know as many ways to do it as possible.) But please type the code here and don't give me any websites to go to that explain it because those end up getting me more confused.
    I also want to launch other files like programs, Word documents and stuff like that.
    Oh and by the way I'm using menuitems to launch the sound so its like:
    case IDM_PLAYSOUND:
    mciSendString("play C:/Sound.mp3 type mpegvideo Alias mpeg", 0, 0, 0);
    return 0;

                                         case IDM_PLAYSOUND:
                                              PlaySound("C:/Sound.mp3", NULL, SND_FILENAME);
                                              return 0;
    
                                         case IDM_PLAYSOUND:
                                              ShellExecute(hwnd, "Sound.mp3", "C:/Sound.mp3", NULL, NULL, 0);
                                              return 0;
    
                                         case IDM_PLAYSOUND:
                                              I forget what I did for sndPlaySound.
    

    All of these things compile but it doesn't play the file and I've checked to make sure of this: the file exists, the volume is all the way up, it's not on mute, the directory is correct, the file has sound. But none of these things work! Please give me the code. But please check to make sure it works on Dev-Cpp first (test it) before you give it to me becase the basis of my program is opening external files and playing music and videos. Oh can you also give me the basis code for a video playing a picture viewing program?

    I know these are REALLY specific questions but I'm not really that great with programming as I just started learning like 6 months ago. But I can look at things in code and understand them really well. If anyone could help I would REALLLLLLLLYYYYYYY appritiate it!!!!!!! :)

     
    • Martian Man

      Martian Man - 2007-09-17

      Hi, umm... I tried both of the things you guys suggested but neither of them work. And I've tried stuff like this on other computers and it doesn't work there either. Please HELP!

       
      • Osito

        Osito - 2007-09-17

        Maybe your sound card is broken? My PlaySound example that plays the system asterisk is about as simple as they come. Are you putting it in one of your menu selections? Are you sure your code is getting there? Are you compiling with -lwinmm? If not, you should get a compile error I would think. I had to link with that library to get access to PlaySound IIRC.

        I would suggest posting your compile log and the code that you are compiling that doesn't work for you. And lay off the CAPS LOCK. It doesn't make us think harder.

         
    • Osito

      Osito - 2007-09-17

      This doesn't quite answer your question, but to test that everything else is OK you could add this:

      PlaySound("SystemAsterisk", NULL, SND_ALIAS | SND_ASYNC);

      and see if it plays the system beep thingy.

       
    • Osito

      Osito - 2007-09-17

      Also I tried your ShellExecute idea and it worked for me (keep in mind that it will spawn an external player rather than just playing the sound):

      ShellExecute(NULL, "open", "c:\temp\start.wav", NULL, NULL, SW_SHOWNORMAL);

      Maybe you can mess with the options to hide the player. All I did was copy a line of code that I use to launch an html help file and stick in the sound file location instead.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.