how do i use windows.h to play .MP3 tracks?

This is a discussion on how do i use windows.h to play .MP3 tracks? within the C++ Programming forums, part of the General Programming Boards category; i was told that in order to play an EXTERNAL .MP3 track, i needed to use <windows.h> and later on ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    6

    how do i use windows.h to play .MP3 tracks?

    i was told that in order to play an EXTERNAL .MP3 track, i needed to use <windows.h> and later on system("..\file.mp3") to play the song

    my problem is, when it has compiled and loaded, i am getting problems about the file not being a proper batch file. is the problem that it is not a full file directory? i want it so that it is dynamic and will change depending on where the program is

    so can someone please help me?

    OS: Windows XP Sp2
    Complier: Dev-C++


    cheers
    Last edited by machineman9; 03-30-2007 at 01:08 PM. Reason: edit title

  2. #2
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719
    You can use the PlaySound() function in windows.h

    However, I believe this only plays .wav and .midi format. You might have to use a sound library or DirectX to play .mp3 format. This should be in Windows Programming board....

    If you want it dynamic, look up a function called FindNextFile() or FindFirstFile()

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    6
    okay thanks, ill have a look around

  4. #4
    For Narnia! Sentral's Avatar
    Join Date
    May 2005
    Location
    Narnia
    Posts
    719
    Also, you may want to look up something called MCI. I think there is an article on gamedev.net ... I forget. There is also a sound library called FMOD which I'm quite sure can play .mp3 format.

    EDIT- Also, FMOD is cross platform.
    Last edited by Sentral; 03-30-2007 at 01:36 PM.

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    you can use mciSendString() which is in mmsystem.h
    although this is a very slow, and CPU intensive way of playing mp3s. I think the easiest API to use is the irrKlang audio API, which plays .wav, .mp3, and ogg vorbis. I cant think of the site right now, but it is at amberia.something I cant remember. it is the API that I use, and it supports 2 and 3 dimensional sounds, and real time audio manipulation.

  6. #6
    Registered User
    Join Date
    Mar 2007
    Posts
    6
    right... i got told you could do it straight off using <windows.h> and the other code i provided...

  7. #7
    Registered User
    Join Date
    Mar 2007
    Posts
    6
    anyone?

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how can i play .MP3 tracks using windows.h?
    By machineman9 in forum Windows Programming
    Replies: 5
    Last Post: 04-05-2007, 10:35 AM
  2. how to play play and stop wav files
    By cnu_sree in forum Linux Programming
    Replies: 4
    Last Post: 08-14-2006, 11:11 PM
  3. pls post here tricks that you know of in C/C++, thanks
    By mickey in forum C++ Programming
    Replies: 55
    Last Post: 06-12-2003, 04:28 PM
  4. Gui Class With Tic Tac Toe
    By xxYukoxx in forum C++ Programming
    Replies: 1
    Last Post: 06-01-2003, 04:28 PM
  5. Cribbage Game
    By PJYelton in forum Game Programming
    Replies: 14
    Last Post: 04-07-2003, 10:00 AM

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