Thread: play MP3 on win32 consol project

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    5

    play MP3 on win32 consol project

    How can i do that ?!

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Code:
    ShellExecute(0, TEXT("open"), path, 0, 0, SW_SHOWNA);
    Do you really think playing MP3s is so trivial? You can call upon other programs to do the playing (as the above line does - it opens your standard media player), but playing an MP3 yourself is not trivial. You need to decode it, and you need to send the decoded data to the soundcard. Complicated.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    5
    I dont want to really read the mp3 file convert it and play it, i just want to add to my application a backround music from mp3 i have.
    How do i do that ?
    i tried to use ShellExecute, but Visual studio 2005 doesnt reconize it... :\

  4. #4

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The matter is complicated. You could do it through an external library or use DirectShow. That's probably the easiest way. There are plenty of sample code on CodeProject to play mp3. Why not give it a look?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    DirectShow is the simplest way to do this short of using a third party library. Keep in mind that DirectShow is no longer a part of DirectX and is available in the Platform/Windows SDK (for XP). They are planning on removing DirectShow completely but I'm not sure if they have or not. They might as well since they already removed everything that is of worth in XP from Vista.

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Er, how will the myriad of video players work, then?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I dunno. But I know there were plans to remove it.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    They plan to remove it!? Are they drinking beer again? :/
    Where did you originally learn this?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I learned it way back when I began writing my DXShowWnd class which wrapped DirectShow. At first I thought it odd that it was no longer in the DX SDK. So I found out it was in the Platform SDK and that eventually it would be merged into something completely different in future versions. I'm not sure if that still holds true today.

    Microsoft changes fundamental designs in the blink of an eye. Unfortunately those decisions have far reaching impacts and are a pain in my arse.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    They are a pain to everyone. Although I wouldn't be sad if they were to upgrade it without the use of COM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Emulator
    Join Date
    Feb 2008
    Posts
    43
    Or you could just make your own background music using system beeps lol. They are featured in the windows library, super easy too! But as he said, it's complicated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 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
  2. Play Mp3...
    By Jperensky in forum C++ Programming
    Replies: 3
    Last Post: 04-26-2003, 02:08 PM
  3. Cribbage Game
    By PJYelton in forum Game Programming
    Replies: 14
    Last Post: 04-07-2003, 10:00 AM
  4. How do I play an MP3?
    By Hunter2 in forum Windows Programming
    Replies: 28
    Last Post: 05-20-2002, 08:49 PM
  5. MP3 Device Type with mciSendCommand
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 04-30-2002, 08:47 PM