/*
 ============================================================================
 Name		 : AudioPlayerEngine.h
 Copyright   : Symbian Academy, 2007
 Description : The audio player engine handles the communication with the
               multimedia framework.
 ============================================================================
 */

#ifndef AUDIOPLAYERENGINE_H
#define AUDIOPLAYERENGINE_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>

// Edit 2: Include the header file required for the CMdaAudioPlayerUtility
//         (see the SDK help for the required include file)


// Edit 3: Add the library required for the CMdaAudioPlayerUtility through 
//         the mmp editor.
//         (see the SDK help for the required library)

/** Engine status */
enum TAudioState
	{
	/** No operation */
	EIdle,
	/** Preparing to play a file*/
	EPlayFilePrepare,
	/** Playing a file */
	EPlayFilePlaying
	};

// CLASS DECLARATION

/**
 * The Audio Player Engine is responsible for handling communication
 * with the Symbian OS audio player interface.
 * The application can request to play a file or to stop playing through
 * functions of this class and will get callbacks of the current status.
 * It also supports certain effects, in case they are supported by the
 * device and/or emulator.
 */
// Edit 4: Additionally derive the class from MMdaAudioPlayerCallback
//         to be able to receive callbacks from the asynchronous service
//         provider - usually, you'd have to implement an active object
//         yourself, but for several of the frameworks this has already
//         been implemented, making it easier for the developer.
class CAudioPlayerEngine : public CBase
	{
public:
	// Constructors and destructor

	/**
	 * Destructor.
	 */
	~CAudioPlayerEngine();

	/**
	 * NewL.
	 * Two-phased constructor.
	 * Create a CAudioPlayerEngine object.
	 * @return a pointer to the created instance of CAudioPlayerEngine.
	 */
	static CAudioPlayerEngine* NewL();

	/**
	 * NewLC.
	 * Two-phased constructor.
	 * Create a CAudioPlayerEngine object.
	 * @return A pointer to the created instance of CAudioPlayerEngine.
	 */
	static CAudioPlayerEngine* NewLC();

private:

	/**
	 * Constructor for performing 1st stage construction
	 */
	CAudioPlayerEngine();

	/**
	 * ConstructL
	 * 2nd phase constructor.
	 * Perform the second phase construction of a
	 * CAudioPlayerEngine object.
	 * @param aRect The rectangle this view will be drawn to.
	 */
	void ConstructL();

public:
	/**
	 * Start to play the specified file.
	 * 
	 * @param aFile complete filename of the sound file,
	 * will be passed directly to the Symbian OS Audio player class.
	 */
	void PlayFileL(const TDesC &aFile);

	/**
	 * Stop playing the audio file if it was currently active.
	 */
	void StopPlay();

	/**
	 * Query if the audio player is currently playing the file.
	 * This is no certain indication if the engine is busy or not,
	 * as it might also be preparing.
	 * 
	 * @return ETrue if a file is currently playing.
	 */
	TBool IsPlaying();

	// Edit 5a: Define the two methods defined in the callback interface
	//          MMdaAudioPlayerCallback (see the SDK help for this class).
	// Edit 5b: Implement those functions (empty for now) in the 
	//          AudioPlayerEngine.cpp file.
	
	
	// Edit 6: If you're working with the S60 3rd Ed. MR-SDK, add the 
	//         "/include/mmf/plugin"-directory of the SDK 
	//         to the system include paths through the mmp editor.

private:
	// Edit 8a: Declare a function called void Cleanup(); that will be
	//          used to reset the state of the engine and to delete
	//          the iAudioPlayer instance.
	
	
private:

	/**
	 * State of the audio engine.
	 */
	TAudioState iState;

	/**
	 * Edit 1: Add an instance variable of type CMdaAudioPlayerUtility*
	 *         and call it iAudioPLayer.
	 */
	};

#endif // AUDIOPLAYERENGINE_H

