You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.2 KiB
90 lines
2.2 KiB
2 years ago
|
//-------------------------------------------------------------
|
||
|
//-------------------------------------------------------------
|
||
|
//-
|
||
2 years ago
|
//- clientmusic.h
|
||
2 years ago
|
//-
|
||
|
//-------------------------------------------------------------
|
||
|
//-------------------------------------------------------------
|
||
|
//- by Roy at suggestion by nekonomicon, based on code by JujU
|
||
|
//-------------------------------------------------------------
|
||
|
//- mp3 player code for HL mod
|
||
|
//-------------------------------------------------------------
|
||
|
//-
|
||
|
//- compatible with version 0.11.9 of Miniaudio
|
||
|
//- https://github.com/mackron/miniaudio
|
||
|
//-
|
||
|
//-------------------------------------------------------------
|
||
2 years ago
|
|
||
2 years ago
|
#ifndef CLIENTMUSIC_H
|
||
|
#define CLIENTMUSIC_H
|
||
2 years ago
|
|
||
2 years ago
|
#define MINIAUDIO_IMPLEMENTATION
|
||
|
#include "../miniaudio/miniaudio.h"
|
||
|
|
||
2 years ago
|
//---------------------------------------------------------
|
||
|
// defines
|
||
|
|
||
|
#define MUSIC_AUDIO_FILE 1
|
||
|
#define MUSIC_LIST_FILE 0
|
||
|
|
||
|
//---------------------------------------------------------
|
||
2 years ago
|
// audio file structure
|
||
2 years ago
|
|
||
|
struct audiofile_t
|
||
|
{
|
||
|
char name [128];
|
||
|
int repeat;
|
||
|
audiofile_t *next;
|
||
|
};
|
||
|
|
||
|
//---------------------------------------------------------
|
||
2 years ago
|
// reader class
|
||
2 years ago
|
|
||
|
|
||
2 years ago
|
class CMusic //: public CHudBase
|
||
2 years ago
|
{
|
||
|
public:
|
||
|
|
||
2 years ago
|
// reading functions
|
||
2 years ago
|
|
||
2 years ago
|
void OpenFile ( char *filename, int repeat ); // open a single file
|
||
|
void OpenList ( char *filename ); // opening a text file containing the files
|
||
2 years ago
|
|
||
2 years ago
|
void Init ( void ); // initialization
|
||
2 years ago
|
|
||
2 years ago
|
void Play ( void ); // playback
|
||
|
void Stop ( void ); // stop
|
||
|
void Reset ( void ); // pause and switch to next track
|
||
|
void Terminate ( void ); // clean-up during termination
|
||
2 years ago
|
|
||
|
// variables
|
||
|
|
||
2 years ago
|
bool m_IsPlaying; // monitors whether the music is played, used to pause the music
|
||
|
bool m_bInit; // checks if the player is initialized
|
||
2 years ago
|
|
||
2 years ago
|
audiofile_t *m_pTrack; // playlist items
|
||
2 years ago
|
|
||
2 years ago
|
// constructor / destructor
|
||
2 years ago
|
|
||
2 years ago
|
CMusic () { m_bInit = false; m_IsPlaying = false; m_pTrack = NULL; Reset(); };
|
||
2 years ago
|
~CMusic () { Terminate(); };
|
||
|
|
||
|
// object instances
|
||
|
|
||
|
ma_result result;
|
||
|
ma_decoder decoder;
|
||
|
ma_device_config deviceConfig;
|
||
|
ma_device device;
|
||
2 years ago
|
|
||
2 years ago
|
// messages
|
||
|
|
||
|
int MsgFunc_CMusicOpen ( const char *pszName, int iSize, void *pbuf );
|
||
|
|
||
|
// monitoring functions
|
||
|
|
||
2 years ago
|
void songEnd();
|
||
2 years ago
|
};
|
||
|
|
||
|
extern CMusic g_MusicPlayer;
|
||
2 years ago
|
#endif // CLIENTMUSIC_H
|