Click here to Skip to main content
15,896,912 members
Articles / Multimedia / DirectX

A DirectX Game: Quadrino

Rate me:
Please Sign up or sign in to vote.
4.89/5 (41 votes)
16 Oct 2008CPOL26 min read 397.8K   6.2K   125  
An interpretation of a popular falling block game implemented with DirectX that attempts to avoid any copyright infringement.
/* MusicPlayer.h **************************************************************
Author:		Paul Watt, Copyright (c) 2002
Date:		10/18/2002
Purpose:	Definition for a class that will play music files using DirectShow.
******************************************************************************/
#ifndef __MUSICPLAYER_H
#define __MUSICPLAYER_H

#include <strmif.h>
#include <atlbase.h>


/* Class **********************************************************************
Author:		Paul Watt
Date:		10/18/2002
Purpose:	The music player is a class that will load a single sound file for 
			playback.  This player will play any format that is supported by
			the current codecs configured with DirectSound.
******************************************************************************/
class CMusicPlayer
{
protected:
	CComPtr<IGraphBuilder>	m_spGraphBuilder;
	CComBSTR				m_MusicFile;

	bool					m_isRepeat;

public:
	CMusicPlayer	();
	~CMusicPlayer	();

	HRESULT SetNotifyWindow(HWND hWnd, long message, long lParam);
	HRESULT HandleEvents ();

	HRESULT virtual GetCurrentFile(CComBSTR &music);
	HRESULT virtual SetCurrentFile(CComBSTR music);

	HRESULT virtual Play();
	HRESULT virtual Pause();
	HRESULT virtual Stop();
	HRESULT virtual Rewind();

	bool IsRepeat ();
	void Repeat (bool isRepeat);

	FLOAT virtual GetVolume ();
	void  virtual SetVolume (FLOAT volume);

	bool	IsPlaying();
};


/* Public *********************************************************************
Author:		Paul Watt
Date:		10/18/2002
Purpose:	Indicates if the music player is currently playing.
Parameters:	NONE
Return:		If the player is playing, then true will be returned otherwise false.
******************************************************************************/
inline bool CMusicPlayer::IsPlaying()
{
	return true;
}


/* Public *********************************************************************
Author:		Paul Watt
Date:		10/22/2002
Purpose:	Indicates if this player is in auto-repeat mode.
Parameters:	NONE
Return:		returns true if this player is in repeat mode false otherwise.
******************************************************************************/
inline bool CMusicPlayer::IsRepeat ()
{
	return m_isRepeat;
}


/* Public *********************************************************************
Author:		Paul Watt
Date:		10/22/2002
Purpose:	Allows the caller to set the repeat mode for this player.
Parameters:	isRepeat[in]: True if the player should automatically restart
				the music track when the EC_COMPLETE event is handled.
Return:		-
******************************************************************************/
inline void CMusicPlayer::Repeat (bool isRepeat)
{
	m_isRepeat = isRepeat;
}


#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
United States United States
I am a software architect and I have been developing software for nearly two decades. Over the years I have learned to value maintainable solutions first. This has allowed me to adapt my projects to meet the challenges that inevitably appear during development. I use the most beneficial short-term achievements to drive the software I develop towards a long-term vision.

C++ is my strongest language. However, I have also used x86 ASM, ARM ASM, C, C#, JAVA, Python, and JavaScript to solve programming problems. I have worked in a variety of industries throughout my career, which include:
• Manufacturing
• Consumer Products
• Virtualization
• Computer Infrastructure Management
• DoD Contracting

My experience spans these hardware types and operating systems:
• Desktop
o Windows (Full-stack: GUI, Application, Service, Kernel Driver)
o Linux (Application, Daemon)
• Mobile Devices
o Windows CE / Windows Phone
o Linux
• Embedded Devices
o VxWorks (RTOS)
o Greenhills Linux
o Embedded Windows XP

I am a Mentor and frequent contributor to CodeProject.com with tutorial articles that teach others about the inner workings of the Windows APIs.

I am the creator of an open source project on GitHub called Alchemy[^], which is an open-source compile-time data serialization library.

I maintain my own repository and blog at CodeOfTheDamned.com/[^], because code maintenance does not have to be a living hell.

Comments and Discussions