Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to play mp3 repeatedly

How to play mp3 repeatedly

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Laffis
    wrote on last edited by
    #1

    To play mp3, I use MCIWndPlay macro. I want to make the tune to be played repeatedly until user wants a stop. Does anyone know how to do it?

    R 1 Reply Last reply
    0
    • L Laffis

      To play mp3, I use MCIWndPlay macro. I want to make the tune to be played repeatedly until user wants a stop. Does anyone know how to do it?

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      You may need to use MCI_PLAY[^] with MCI_DGV_PLAY_REPEAT flag. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      L 1 Reply Last reply
      0
      • R Ravi Bhavnani

        You may need to use MCI_PLAY[^] with MCI_DGV_PLAY_REPEAT flag. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        L Offline
        L Offline
        Laffis
        wrote on last edited by
        #3

        (I am bing daft here - I have not much knowledge of mm programming.) I wanted to use mci functions but hit a rock, because I do not know how to retrieve device id, and the device id is required to send the commands. Can you shed some light or point me to relevent sites? I tried but could not find any example telling me how to get the id, i.e. what name should I use in MCIDEVICEID mciGetDeviceID( LPCTSTR lpszDevice ); I think once I know how to retrive the device Id I should be able to cook. PS I looked at the system.ini file, as a few internet findings suggest, but found nothing under the [mci] section.

        R 1 Reply Last reply
        0
        • L Laffis

          (I am bing daft here - I have not much knowledge of mm programming.) I wanted to use mci functions but hit a rock, because I do not know how to retrieve device id, and the device id is required to send the commands. Can you shed some light or point me to relevent sites? I tried but could not find any example telling me how to get the id, i.e. what name should I use in MCIDEVICEID mciGetDeviceID( LPCTSTR lpszDevice ); I think once I know how to retrive the device Id I should be able to cook. PS I looked at the system.ini file, as a few internet findings suggest, but found nothing under the [mci] section.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Assuming you know the name of the .mp3 file (I'm boldly assuming it's a file), you can simply do:

          // Start playing the file
          char szMp3File [MAX_PATH];
          strcpy (szMp3File, "C:\\myFile.mp3");
          VERIFY (::sndPlaySound (szMp3File, SND_LOOP | SND_ASYNC));

          ...

          // Stop playing the file
          VERIFY (::sndPlaySound (NULL, 0));

          /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

          L 1 Reply Last reply
          0
          • R Ravi Bhavnani

            Assuming you know the name of the .mp3 file (I'm boldly assuming it's a file), you can simply do:

            // Start playing the file
            char szMp3File [MAX_PATH];
            strcpy (szMp3File, "C:\\myFile.mp3");
            VERIFY (::sndPlaySound (szMp3File, SND_LOOP | SND_ASYNC));

            ...

            // Stop playing the file
            VERIFY (::sndPlaySound (NULL, 0));

            /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

            L Offline
            L Offline
            Laffis
            wrote on last edited by
            #5

            I tried the sndPlaySound(...) and passed in a .mp3 file but the mp3 file did not get played. instead, a wav file was played. I guess it is because this func works only for wav file so a default sound was played rather than the mp3 specifed. In fact before I use the mp3, I was playing a wav file instead, using the PlaySound(...), which is similar to this one you suggested. I thought I should move up the ladder a bit by tackling more advanced multimedia stuff, which means the application can be more flexible. This is the background info of how I got here... Do u happed to know how to get device id? It is really nice to know.

            R 1 Reply Last reply
            0
            • L Laffis

              I tried the sndPlaySound(...) and passed in a .mp3 file but the mp3 file did not get played. instead, a wav file was played. I guess it is because this func works only for wav file so a default sound was played rather than the mp3 specifed. In fact before I use the mp3, I was playing a wav file instead, using the PlaySound(...), which is similar to this one you suggested. I thought I should move up the ladder a bit by tackling more advanced multimedia stuff, which means the application can be more flexible. This is the background info of how I got here... Do u happed to know how to get device id? It is really nice to know.

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #6

              Perhaps this[^] article will help?  Btw, I use BASS[^] to play MP3 files.  I've also heard good things about FMOD[^]. Good luck! /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups