2010-09-29 17:29:43 +08:00
|
|
|
#ifndef _SOUNDPLAYER_UPHONE_H_
|
|
|
|
#define _SOUNDPLAYER_UPHONE_H_
|
|
|
|
|
|
|
|
#include "TG3.h"
|
|
|
|
#include "TCOM_MediaPlayer_Method.h"
|
|
|
|
#include "TCOM_Generic_DataType.h"
|
2010-10-13 14:18:03 +08:00
|
|
|
#include <string>
|
2010-09-29 17:29:43 +08:00
|
|
|
|
2010-12-15 18:28:18 +08:00
|
|
|
namespace CocosDenshion {
|
|
|
|
|
2010-10-21 10:21:24 +08:00
|
|
|
class SoundPlayer
|
2010-09-29 17:29:43 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SoundPlayer();
|
|
|
|
~SoundPlayer();
|
|
|
|
|
|
|
|
void Release();
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Play sound file on the hard disk
|
|
|
|
@param pFileName The absolute path of the file
|
|
|
|
@param nTimes The loop times of playing,If the value is -1,it will loop forever
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
void PlaySoundFile(const char* pFileName, Int32 nTimes = 1);
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Play sound data in memory
|
|
|
|
@param pData The pointer of sound data
|
|
|
|
@param nSize The size of sound data
|
|
|
|
@param nTimes Loop times,default value is 1.
|
|
|
|
@param pFileName The file name of sound data,default value is empty string
|
|
|
|
@warning The file name must have extension,the extension affect the decode mode of the playing.
|
|
|
|
So the extension must as same as the original file.
|
|
|
|
If keep it empty string,the sound data will be decode as wav file.
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
2010-10-21 10:21:24 +08:00
|
|
|
void PlaySoundFromMem(UInt8* pData, Int32 nSize, const char* pFileName = "", Int32 nTimes = 1);
|
2010-09-29 17:29:43 +08:00
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Set the player volume
|
|
|
|
@param nValue The volume value,must between 0 and 100
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
void SetVolumeValue(Int32 nValue);
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Pause playing
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
void Pause();
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Resume Playing
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
void Resume();
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Stop Playing
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
void Stop();
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Rewind Playing
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
void Rewind();
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Set the player mute or not
|
|
|
|
@param bMute Whether mute or not
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
void Mute(bool bMute);
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Whether the player is playing or not
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
bool IsPlaying();
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Decode the file data
|
|
|
|
@param buffer [out] The data after decode
|
|
|
|
@param pszFilePath The absolute path of sound file
|
|
|
|
@return If success return value >= 0,or return value < 0
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
Int32 DecodeFile(void* buffer, Int32 bufferLen, const char* pszFilePath);
|
|
|
|
|
|
|
|
/**
|
2010-11-12 16:33:50 +08:00
|
|
|
@brief Get the size of file buffer
|
|
|
|
@param pszFilePath The absolute path of sound file
|
|
|
|
@return If file existed return the data size,or return -1
|
2010-09-29 17:29:43 +08:00
|
|
|
*/
|
|
|
|
Int32 GetFileBufferSize(const char* pszFilePath);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Boolean OpenAudioFile(const char* pszFilePath);
|
|
|
|
|
|
|
|
private:
|
|
|
|
TCOM_MediaPlayer_Method_Play *m_pPlayer;
|
|
|
|
TCOM_DataType_SysFile *m_pMediaFile;
|
|
|
|
|
2010-11-12 16:33:50 +08:00
|
|
|
TCOM_MethodEmun m_MethodEmun;
|
2010-09-29 17:29:43 +08:00
|
|
|
|
|
|
|
TUChar m_fileName[MAX_PATH];
|
|
|
|
};
|
|
|
|
|
2010-12-15 18:28:18 +08:00
|
|
|
} // end of namespace CocosDenshion
|
|
|
|
|
2010-09-29 17:29:43 +08:00
|
|
|
#endif
|