Playing wma files

This is a discussion on Playing wma files within the C++ Programming forums, part of the General Programming Boards category; How to play wma files?...

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    Playing wma files

    How to play wma files?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >How to play wma files?
    How to search google? Seriously, this is a common question, so a decent google search will quickly give you a suitable answer.
    My best code is written with the delete key.

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    Well, Windows Media Player is pretty good at playing it's own format

    Google OpenAL, FMOD and DirectSound.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    #include <windows.h>
    #include <stdio.h>
    
    #if defined(_MSC_VER)
    #  pragma comment(lib, "Winmm.lib")
    #endif
    
    /*
     * Plays an MP3 or WMA file.
     */
    BOOL PlaySong(LPCTSTR szFile)
    {
    	TCHAR szCommandString[1000];
    
    	wsprintf(szCommandString, TEXT("open \"%s\" type mpegvideo alias MediaFile"), szFile);
    
    	/* By default mci functions will return immediately and the task will be carried out
    	 * asynchronously. To have the function wait, place the word "wait" at the end of the
    	 * command string. ie. "play MediaFile wait" */	 
    	if (ERROR_SUCCESS == mciSendString(szCommandString, NULL, 0, NULL) &&
    	    ERROR_SUCCESS == mciSendString(TEXT("play MediaFile"), NULL, 0, NULL))
    	{
    		return TRUE;
    	}
    
    	return FALSE;
    }
    
    int main(void)
    {
    	if (!PlaySong(TEXT("C:\\Path To\\Your Song.wma")))
    	{
    		printf("Failed to play song!");
    	}
    
    	getchar();
    	return 0;
    }
    To play it in Windows Media Player, you could use system or ShellExecute.

  5. #5
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Ok, thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  2. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  3. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. playing .mmf files
    By Ruski in forum Windows Programming
    Replies: 2
    Last Post: 06-17-2005, 09:49 PM

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